SQL Query Optimization Tool: The Issue with Point Queries

f:id:TosskaTechnologies:20200814203154p:plain

Databases are rather intricate systems comprising many aspects. Here, we will talk about the part that interacts with storage hardware, i.e., the storage engine. This is one of those sections that have to deal with queries, updates, transactions, compression, and concurrency.

Our previous blog was about range queries and why they are suitable for larger databases. This time, we will cover point queries and their features in terms of disk limit performance related to various operations. If you feel the need for performance tuning in your database, look for a trustworthy SQL query optimization tool, like the ones offered by Tosska Technologies Ltd.

 

Point Queries: Slowing Down Performance in MySQL?

Most Database Administrators are asked about the speed of the queries used in their databases. Since we are talking about point queries, these are rather time-consuming; one way of understanding their speed is by considering the following example. Suppose a hard disk of 1 TB with a disk seek time of 14ms and approximately 68 Megabytes per second of transfer speeds, like we did with range queries in the previous blog.

Next, suppose we are occupying the entire space with a single table that consists of 62.49 billion rows, each containing two integers of eight bytes separately. The manner in which this data is stored is of no consequence in our example - we will only pay attention to the part where we attempt to access said stored data in a random sequence. 

f:id:TosskaTechnologies:20200814203359p:plain

Disk seeking is important when we perform random point queries. As a result, the total time taken to gain access to each data point is more than 27 years, if the system does not have any other tasks taking up process time. In other words, reading data that consist of small records that completely fill a database can take upwards of a few decades.

This is a simple example, but practically speaking, you may face different advantages or challenges during data insertion which may require the intervention of a SQL query optimization tool instead. For instance, the disk may have lower seek times, but the file system may not allow complete disk occupation. Perhaps the capacity per row is larger than 8 bytes. In the end, you may be able to save lots of time depending on the disk and system conditions, but the total time is still likely to extend over several years, at the minimum.

Fixing the Point Query Issue through Performance Tuning in SQL MySQL

Another thing to remember is that these observations are not dependent on the method of data storage employed. Because of this, some methods of performance tuning in SQL MySQL, like applying software resolutions or remedies related to data structures, will not work here.

In this case, scattering data across multiple smaller disks may partially solve your issue down the road, by pipelining the point query stream. After this, ensure that the depth is maintained at 10 - that would enable 10 disk seek operations to be carried out on ten separate disks at the same time.

 

f:id:TosskaTechnologies:20200814203501j:plain

However, it may get cumbersome to ensure that you perform only a single disk seek per disk at a particular instant in time. Otherwise, you can end up with the same search being performed multiple times on the same disk, which would return the same results and waste valuable time.

 

SQL Query Optimization Tool: Performance Tuning in SQL MySQL

After all this trouble, you will manage to complete all the point queries in around three years - just a fraction of the time it would take on a single disk, but still way too long, especially considering all the effort. To fix things further means applying parallelization at a large scale for a semblance of acceptable performance, which is not very practical.

This is why DBAs prefer range queries to handle big databases required by corporations. If you want to implement a huge database with tasks that mostly include point queries, then the only way of MySQL database and SQL is through hardware, preferably a different route than several hard disks.

 

f:id:TosskaTechnologies:20200814203545j:plain