MySQL Flashcards
What 3 levels of MYSQL database consist from?
- Connection and security ( Check if you can get access to data)
- Optimization and performing ( overbuilding request, caching, select indexes etc..)
- Respond to requests
What kind of locking do you know?
- Row-Level Locking ( blocks only specific row)
2. Table Locking ( blocks all table )
What is ACID?
ACID is an acronym that describes four properties of a robust database system: atomicity, consistency, isolation, and durability.
- Atomicity
- Consistency
- Isolation
- Durability
What is transaction isolation level? What transaction isolation levels do you know?
Isolation levels define the degree to which a transaction must be isolated from the data modifications made by any other transaction in the database system
- Read uncommitted (Dirty read )
- Read committed (Non Repeatable read)
- Repeatable read (Phantom Read )
- Serilializable
What is database transaction deadlock?
In a database, a deadlock is a situation in which two or more transactions are waiting for one another to give up locks.
For example, Transaction A might hold a lock on some rows in the Accounts table and needs to update some rows in the Orders table to finish. Transaction B holds locks on those very rows in the Orders table but needs to update the rows in the Accounts table held by Transaction A. Transaction A cannot complete its transaction because of the lock on Orders. Transaction B cannot complete its transaction because of the lock on Accounts
Where do we store MySQL tables?
In file system. MySQL creates file with .frm extension for each table and store data there ( for example animal.frm)
What is MVCC?
Multi versioning concurrency control (MVCC) is a database design theory that enables relational databases to support concurrency, or more simply multiple user access to common data in your database.
What kind of measure for testing db performance do you know?
- Throughput ( How many transaction per second available?)
- Response time ( How long time response can tike? )
- Paralelizm ( How many thread can work in the same time?)
- Scalability ( How will your system behave if you double number of users? Linear dependency or other? )
What steps you can do to test your database?
- Create a snapshot of your db (anon db)
- Save all request in the most loaded time ( from logs)
What is Profiling?
MySQL query profiling is a useful technique when trying to analyze the overall DB performance ( Gives you information about db performance)
Why do you need trigger?
You can use a trigger to backfill table column with duplication values to optimize select request from the table ( denormalization)
What is a shadow copy?
It allows you to create a new table, do ALTER operation there to not block the main table, then replace them.
What commands can block the whole table?
- ALTER TABLE
What can slow down your DB requests?
- When you request more data than you need and then filter it on the program level ( Request unnecessary rows)
- When you request the same data on the same page many times instead of caching
- When we use a full scan table instead of indexes
- When you send many small requests and combine them instead of creating one big ( For example you request to select each column name 10 times one by one instead of 1 request to get all together)
- Hardware problem. When you send too many concurrency requests at the same time
How caching understand that existing data haven’t changed (not outdated )?
- Looks like insert/update/delete operations can affect cache and invalidate it
- The second option is the expiration time for cache