Time and again, this is due to the application queries not using the right indexes, or even using any indexes at all. The queries can be well written, as I usually keep repeating to the developers how important that is. On the other hand, I keep telling everybody about the usefulness of indexes, and somehow that doesn't seem to stick...
So, let's try this one more time ;-)
If you write a query (any query), it is important to ask yourself a few questions:
- What data will this query access
- How are the tables in this query connected. Am I using the right connections (comparing the right attributes)
- Am I using the right filter conditions on the data
These are questions of a more logical nature. This has everything to do with constructing a good query. The "hard" part is the technical part of the puzzle:
- How will the database access my data
- Are there enough fast access paths (at least one) to choose from
- Will this query perform when retrieving the needed amount of data
So, to all developers out there, please consider your queries carefully. After creating the query, try to anticipate how it will function. If there is any doubt if the query will perform adequately, at least test it with a representative amount and distribution of data.
Of course, I am fully aware of the many types of queries out there, not to mention the many types of indexes you can use. Usually, it pays off to invest some time reading up on the use of indexes. There are a great number of resources to use out here on the internet, so I won't even try to begin explaining them. As a developer, do yourself a favor and spend some time getting to know the workings of the most common types of indexes.
And if all else fails: please contact your DBA...
No comments:
Post a Comment