Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Database Design and Application Architecture
 Speeding up site by storing query results in file

Author  Topic 

astroman22
Starting Member

1 Post

Posted - 2008-03-04 : 23:22:19
Hello,
We have some queries that are long and intensive. We have thought about running the queries and storing the data in a text file for lookup from our website.

Example: Our online store only displays items that are in stock so when a user selects a category a query runs and grabs only items that are in stock and then displays them. There could be thousands of items the query needs to sort through before displaying the items that are in stock. What if we ran this query once every hours an stored the results in a txt file? The asp page would then go to the text file to grab the results instead of having to run the query every time a user selects a category. Will this speed up the site by not having to query every time? Would this be a correct way to eliminate queries that run thousands of times a day?

thanks
Andy

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2008-03-04 : 23:39:15
If you do this then don't store the results in a text file, store them in another SQL Server table!
Other options would be Analysis Services if the queries return highly aggregated results, or caching in your web application (.NET has various options for doing this, and SQL Server 2005 supports this with query notifications).
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2008-03-05 : 02:41:37
Caching data that doesn't change that often is a very good performance booster so I say go for it. But you have to be aware that your customers could end up beeing displayed the wrong amount of items in stock, but if you can live with that then it's no problem.

A table in the database is much better than a file on the filesystem. Alot easier to populate and alot easier to query when you only want only parts of the result set.

--
Lumbago
"SELECT Rum, Coke, Lime, Ice FROM bar WHERE ClosingTime = 'Late' AND FemaleMaleRatio > 4"
Go to Top of Page
   

- Advertisement -