MySQL Flashcards
(37 cards)
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
What is a database table partitioning ( секционирование )?
Partitioning is the database process where very large tables are divided into multiple smaller parts. By splitting a large table into smaller, individual tables, queries that access only a fraction of the data can run faster because there is less data to scan. The main of goal of partitioning is to aid in maintenance of large tables and to reduce the overall response time to read and load data for particular SQL operations.
What is a trigger?
Trigger allows to run code after one of the following operations CREATE, UPDATAT OR DELETE
What is database event?
This is something similar to cron job. It allows you to run code at a specific time.
What is distributed transaction?
A distributed transaction is a set of operations on data that is performed across two or more databases. ( transaction between several databases)
What is replication? Why do we need it?
Replication is a copy of DB on another server.
We need it to:
- distribute load between several servers
- backup data
- switch on to replica when emergency
- testing new features
What relations between replications servers you know?
- One main server and many child servers
- Main to main ( bidirectional )
- Main to main ( bidirectional but the second one is passive can only read data)
What is scalability?
It’s the ability to scale the system when it’s necessary and has a good proportion between resources and workload.
What kind of scalability do you know?
- Vertical scaling ( Improve current hardware )
- Horizontal scaling ( Adding more hardware to a system)
How to implement horizontal scaling?
- Create replications (read only)
- Separate debates to independent parts ( as contexts )