Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 DATABASE


  Why (offset, limit) is slow in database select?

Starting from a problemFive years ago when I was working at Tencent, I found that MySQL request speed was very slow in the pagination scenario. With only 100,000 data, a select query on a single machine took about 2-3 seconds. I asked my mentor why, and he asked in return, "In an indexing scenario, what is the time complexity to get the nth largest number in MySQL?"The pursuit of the answerConfirming the scenarioAssuming there is an index on the "status" column, a query like "select * from table where status = xx limit 10 offset 10000" will be very slow. Even with a small amount of data, there...

2,737 0       MYSQL OFFSET LIMIT SLOW


  Why MySQL 8 drops support of query cache

Many of you may have heard or used MySQL's query cache, because it used to be a popular way to improve MySQL's performance. As an important feature for improving MySQL's performance, the query cache was often recommended as a solution for slow queries. However, why has MySQL 8 abandoned the query cache? Today, we will analyze and explore this decision.What is query cache?According to official document:The query cache stores the text of a SELECT statement together with the corresponding result that was sent to the client. If an identical statement is received later, the server retriev...

1,771 1       MYSQL 8 QUERY CACHE


  A guide on installing and running Clickhouse on macOS

ClickHouse is a high-performance open-source columnar database management system developed by Yandex. Here are some of the key features of ClickHouse:Columnar storage: ClickHouse uses a columnar storage format, which allows it to efficiently store and retrieve data by column, rather than by row. This results in much faster query performance, especially for analytical and aggregate queries.Real-time data processing: ClickHouse is designed to handle real-time data processing and can handle billions of rows of data with sub-second query times.Massively scalable: ClickHouse can scale to handle mas...

3,988 1       CLICKHOUSE MACOS


  What is blocking and how would you troubleshoot it?

Blocking is a common occurrence in an SQL server context, but if you are new to the world of database management you might not know what this issue entails and perhaps even fear that it is a sign of serious underlying problems.To allay your fears and clear up the mystery, here is a brief overview of blocking and the steps you can take to tackle it.Image Source: PixabaySQL blocking explainedSQL blocking according to SentryOne is an offshoot of the way that concurrent databases operate. Because processes can be executed simultaneously, it is likely that at some point more than one process will n...

1,549 0       SQL DEADLOCK


  Guide on recovering data in MySQL

In our daily work, there might be mistakes made which got some data or even databases deleted in MySQL. If this happens on production, it would be a nightmare. In case this happens, normally DBA would jump in to save the world. And they would try to recover the data from the backup if there is any. But if there is no backup, then the show stops.Hence database backup is necessary on production environments to avoid such awkward situation. Also normally in MySQL, binlog should be enabled as well in ROW mode so that recovery can be replayed starting from the backup time point to the incident time...

3,394 0       BINLOG EXAMPLE DATABASE MYSQL BACKUP


  How Query Optimizer Works in RDBMS

In a previous post, we discussed how the various relational operators are implemented in relational database systems. If you have read that post, you probably still remember that there are a few alternative implementations for every operator. Thus, how should RDBMS determine which algorithm (or implementation) to use?Obviously, to optimize the performance for any query, RDBMS has to select the correct the algorithm based on the query. It would not be desirable to always use the same algorithm. Also, SQL is a declarative language (i.e., as a programmer we only declare what we want to ...

8,034 0       DATABASE DATABASE DESIGN DATABASE OPTIMIZATION


  Understanding How is Data Stored in RDBMS

We all know that DBMS (database management system) is used to store (a massive amount of) data. However, have you ever wondered how is data stored in DBMS? In this post, we will focus on data storage in RDBMS, the most traditional relational database systems.Physical StorageData can be stored in many different kinds of medium or devices, from the fastest but costy registers to the slow but cheap hard drives, or even magnetic tapes. Nowadays, IaaS providers such as AWS even provides services such as S3 Glacier as a low-cost archiving storage solution. The...

11,911 0       RDBMS DATABASE


  How to reset root password in MySQL 8

The user password in MySQL is stored in the user table, the password reset is actually to change the value of record in this table. To change the password in case the password is forgotten, the idea is to bypass the authentication of MySQL and get into the system and update the record password value with SQL command.In MySQL 5, one can start MySQL service with --skip-grant-tables option, this option will tell the service to skip loading the grant tables when starting, hence the root user can login with empty password.mysqld –skip-grant-tables After login, can run below SQL command t...

59,997 5       MYSQL PASSWORD MYSQL 8