Topic > Database Optimization: Save Time and CPU Usage

Database optimization is something that, although it may go unnoticed, is very important for saving time and CPU usage. Trying to query the mathematical database downloaded from the StackExchange module. A query is an expression written in a programming language, in this case SQL, used to search for data in a database. Stackexchange is a large compressed file that contains a record of all forums on the stackoverflow.com website. I specifically used the math files since they are among the largest files and serve as a perfect example of why database optimization and finding efficient SQL queries is important. I've noticed that complicated queries can be optimized to get faster and more complete results. With the size of the files I was using to create my database, each ranging between 30 megabytes and 600 megabytes, I inserted a few hundred thousand rows of data into my tables, even simple queries, like "SELECT * FROM post", which normally taking less than a second to run, they used to take up to 10 or 15 seconds. From experimentation and research, the best way to speed up queries is to know your database, be specific, and use techniques like indexes. The article Query Optimization in Database Systems by Matthias Jarke and Jurgen Koch also shows the continued importance of finding a way to make queries efficient when using a database system. “Efficient methods of processing unexpected queries are a crucial prerequisite for the success of generalized database management systems.” (Query Optimization in Database Systems) The document also explains the importance of knowing the database and what you are looking for. Also explained is the importance of finding alternative ways to ask a question... mid-paper... to reduce the time spent waiting for a question to finish. The biggest improvements came from the use of indexes and joins. Using an index made queries have some sort of reference when searching and performing operations on specific columns. Joins reduced the amount of operations the system had to process and made the biggest difference in execution time. As databases grow, it is important to try to reduce overall costs by optimizing queries.Works Cited"2012-02-15Slow Indexes, Part II." Slow SQL indexes. Np, nd Web. 10 April 2014. "2.6. Joins between tables." PostgreSQL: Documentation: 8.3: Joins between tables. Np, nd Web. April 10, 2014."CREATE INDEX." PostgreSQL: Documentation: 9.1: CREATE INDEX. Np, nd Web. April 10, 2014."Query Optimization in Database Systems." Query optimization in database systems. Np, nd Web. April 10. 2014.