In Databases, If A Query Is Taking A Lot Of Time To Execute, What Could Be The Reason If It Worked Quickly Only The Day Before?
Answers
There are two things which, if both are true, could make the query run much more slowly.
The first is that the database now has a lot more data in it and so there are more rows to be searched. But usually this is unlikely to happen the next day, unless you have been using a small set of data in some tests, and then uploaded a huge set of data for the final production version of the database. Even then this is unlikely to have a big effect, as indexes are designed to remove this problem. You do use indexes, don't you?
The most obvious one is that the query is badly written and has several extra steps in it which force it to re-do things again and again. A typical example would be a query with a sub query inside it. Often the sub-query can be run once, the data stored in memory, and then each row compared to the stored data. But if the sub query has to use data which is specifically related to the main query, then it has to run through the entire table every time it examines a single row for the main query! So for 100 rows, 100x100 execution steps occur.
So if the query is badly written and the database has got a bit bigger, the query will get slower and slower as more data is added.
If it is really badly designed, it might be doing a cartesian join between tables and everything will grind to a halt if that occurs on a big data set!
answered 2 years ago
- This guy I like a lot from work gave me his number before I got out the car after he dropped me off at home. I really like him but at work h...
- I bought a Virgin mobile slice yesterday, and I'm supposed to have a certain plan with nights and weekends free. But it didn't work and toda...
- My husband and i are trying to have a baby. We had sex 1 time 2 days before ovulation, 2 times 1 day before ovulation and 1 time after ovula...
- My TV Blinks 8 Times In The Stand By Mode.I Unplugged It And It Worked Once The Next Day It Was Back To Blinking Now It Will Not Come On Ag...
- We Had Sex 12-13 Days Before My Last Period...and I Was Still On Time This Month. Could I Still Be Pregnant?



