Victor's Blog

Live as if you were to die tomorrow. Learn as if you were to live forever

NAVIGATION - SEARCH

Improve the blogengine.net performance in Godaddy hosting

I recently upgraded my hosting plan from shared hosting to 4GH grid hosting in Godaddy. It was a really bad idea. The 4GH performance is insanely bad. It takes about 30 seconds to load my homepage. I googled the Godaddy performance. It seems a lot of people have the same issue and Godaddy seems don't care about resolve this issue at all. So I have to do some tweaks to ensure my site's performance is reasonable. Here is two things I did which helped the most:

1. Precompile the site. This is very very important.  According this post, Godaddy puts about 3900 sites in one server. That means you have to compete resource with them. Compiling you website dynamically is not a good idea anymore. Precompiling the website will make you lose some of the flexibility. But it makes sure you don't have to compete resource to compile the website anymore. 

2. Only display one entry per page. It makes sure you site only load the small amount of the data every time. You can set that in your blog setting.

After these two steps, I reduced the loading time from 30 seconds to about 5 seconds. Good luck to you guys.

The Poor Little Ant

Every day, a small Ant arrived at work early and started work immediately. She produced a lot and she was happy. The boss, a lion, was surprised to see that the ant was working without supervision. He thought if the ant can produce so much without supervision, wouldn’t she produce more if she had a supervisor!

So the lion recruited a cockroach who had extensive experience as a supervisor and who was famous for writing excellent reports. The cockroach’s first decision was to set up a “clocking in” attendance system. He also needed a secretary to help him write and type his reports. He recruited a spider that managed the archives and monitored all phone calls.

The lion was delighted with the cockroach’s report and asked him to produce graphs to describe production rates and analyze, trends so that he could use them for presentations at board meetings, so the cockroach had to buy a new computer and a laser printer and recruit a fly to manage the It department. The Ant, who had been once so productive and relaxed, hated the plethora of paperwork and meetings which used up most of her time.

The lion came to the conclusion that it was high time to nominate a person in charge of the department where the ant worked. The position was given to the Cicada whose first decision was to buy a carpet and an ergonomic chair for his office. The cicada also needed a computer and a personal assistant, who he had brought form his previous department. To help him prepare a work and budget control strategic optimization plan.

The department where the ant works is now a sad place, where nobody laughs anymore and everybody has become upset. It was at that time the cicada convinced the boss, the Lion to start a climate study of the environment. Having reviewed the charges of running the ants department the lion found out that the production was much less than before, so he recruited the Owl, a prestigious and renowned consultant to carry out an audit and suggest solutions. The owl spent 3 months in the department and came out with an enormous report, in several volumes, That concluded that ” The Department is overstaffed!”

Guess who the lion fired first?

 

The Ant of course, because everyone superior to the Ant blamed her, the worker.

Search a value from the whole database

If you ever want to search something from the database but you don't know which tables to search from, here is the query you need:

/****** Script for SelectTopNRows command from SSMS  ******/
SET NOCOUNT ON

DECLARE
   @TotalRows   int,
   @Counter     int,
   @TableName   varchar(50),
   @ColumnName  varchar(50),
   @FieldValue  varchar(250),
   @SQLCommand  nvarchar(1000),
   @ValueToFind varchar(100)


SET @ValueToFind = 'VAULE TO SEARCH'

DECLARE @MyTable table
   (  RowID      int IDENTITY,
      TableName  varchar(50),
      ColumnName varchar(50)
   )

CREATE TABLE #FoundTable
   (  RowID      int IDENTITY,
      Tablename  varchar(50)
   )

INSERT INTO @MyTable
   SELECT
      TABLE_NAME,
      COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE DATA_TYPE IN ( 'char', 'varchar', 'nchar', 'nvarchar', 'text', 'ntext' )

SELECT
   @TotalRows = @@ROWCOUNT,
   @Counter   = 1

WHILE ( @Counter <= @TotalRows )
  
   BEGIN
 
      SELECT
         @TableName = TableName,
         @ColumnName = ColumnName
      FROM @MyTable
      WHERE RowID = @Counter
    
      SET @SQLCommand = 'IF EXISTS ( ' +
                        'SELECT 1 FROM [' + @TableName + '] WHERE [' + @ColumnName + '] LIKE ''%' + @ValueToFind + '%'' ' +
                        ' )' +
                        'INSERT INTO #FoundTable ' +
                        '   SELECT ''' + @TableName + '(' + @ColumnName + ')'''

      EXECUTE sp_executesql @SQLCommand
     
      SET @Counter = ( @Counter + 1 )
  
   END

SELECT * FROM #FoundTable

DROP TABLE #FoundTable