computer_science:databases:mysql:mysql_tips_trics

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
computer_science:databases:mysql:mysql_tips_trics [2021/03/07 17:02] carlossousacomputer_science:databases:mysql:mysql_tips_trics [2023/12/01 12:07] (current) – external edit 127.0.0.1
Line 5: Line 5:
 ===== Use Indexes ===== ===== Use Indexes =====
  
-Pros: Massive increase in searching performance.+**Pros:** Massive increase in searching performance.
  
-Cons: Slightly Increase in Storage Requirements. Slightly Increase on Write speeds.+**Cons:** Slightly Increase in Storage Requirements. Slightly Increase on Write speeds.
  
-Usage:+**Example:**
 <code> <code>
  
Line 15: Line 15:
  
 </code> </code>
 +
 ===== Enforce Data Integrity at the DB Level ===== ===== Enforce Data Integrity at the DB Level =====
  
-ProsApplication agnostic Data Integrity+**Eg.**unique constraints, cascade deletes
  
-Cons-+**Pros**Application agnostic Data Integrity
  
-Instead of:+**Cons:** - 
 +===== Log Queries in Development ===== 
 + 
 +**Pros: **Great to see Queries happening in Real Time 
 + 
 +**Cons: **Slightly higher storage requirement 
 + 
 +Don't forget to disable in Production 
 + 
 +**Usage:** 
 + 
 +Update my.cnf and add / change:
  
 <code> <code>
-posts table +general_log_file = /var/log/mysql_queries.log 
-- post_id +general_log = 1
-- title +
-- author_name+
  
 </code> </code>
  
-Do:+check log with:
  
 <code> <code>
-posts table +tail -f /var/log/mysql_queries.log
-post_id +
-- title +
-- author_id+
  
-authors table +</code> 
-author_id +===== Use Transactions for bulk insert: ===== 
-name+ 
 +**Pros:** Only one re-index, at the end of the transaction. 
 + 
 +**Cons: **Visibility of new data only after commit this can be considered an upside -. 
 + 
 +**Usage:** 
 +<code> 
 +START transaction; 
 +insert into table values (default, 1); 
 +insert into table values (default, 2); 
 +insert into table values (default, 3); 
 +insert into table values (default, 4); 
 +insert into table values (default, 5); 
 +COMMIT;
  
 </code> </code>
  
  
  • computer_science/databases/mysql/mysql_tips_trics.1615136566.txt.gz
  • Last modified: 2023/12/01 12:07
  • (external edit)