SQl problem
hello all,
I don't know where should I need to ask this question.... I am having some weird problem with SQL server 2000... sometimes it is woking fine and retrieving data within a second...and sometime the same query I type in SQL analyser and it takes more than 5mins to display the data...I made few indexes on fields.... can anyone help me please with this problem?is there any internal setting in SQL that I need to do?.. I have 5million records in my database...
radhika...
Is it always the same WHERE clause? If not, it could be that some of your queries involve simple equality on indexed fields and therefore run fast, while others require a full table scan and run very slowly because they use LIKE or access unindexed fields.
btw, MSDN has a SQL Server forum, although tey may have forgotten about SQL2000. Have you tried this on SQL2005? The developer edition is a full enterprise edition, and it costs about $50 US. The Express edition is free.
guys,
thatnks for the quick reply.....my problem is this, problem stays for few mins only... so after a while if I run the same query it get me data faster...is that a possibility that some of my connection is creating problem?... I am opening and closing connection in my program frequently...
please reply..
thanks
Radhika.
There are several ways I can think of the top of my head to speed up getting query results:
1) Use store procedure
2) Use materialized view
3) Use prepared statement
4) Make sure your database is properly normalized (which could lead to smaller tables)
5) Index the field you are searching on (B+ Tree if range predicate and Hash/B+ Tree for equality)
...
> my problem is this,
> problem stays for few mins only... so after a while
> if I run the same query it get me data faster...is
> that a possibility that some of my connection is
> creating problem?... I am opening and closing
> connection in my program frequently...
It usually takes longer for the first query to run than subsequent executions of the same query. A query plan has to be generated the first time which can be expensive.