May 24, 2012

Post: Using delayed JOIN to optimize count(*) and LIMIT queries

…(*) queries for such result sets MySQL will perform the join even if you use LEFT JOIN so it is not needed which slows down… very expensive. To get better performance you can “Help” MySQL and remove JOIN for count(*) and do JOIN after limiting result set for… select count(*) from fact left join dim on val=id where i select i,pad from fact left join dim on val=id where…

Post: Using CHAR keys for joins, how much is the overhead ?

… time. OK. Lets start with first simple MyISAM table and join query performed on INT fields: CREATE TABLE `intjoin` ( `i` int(10…+t2.j+length(t2.c)+t1.j) from intjoin t1 left join intjoin t2 on t1.i=t2.j; +———————————-+ | sum(t1.i…+t2.j+length(t2.c)+t1.j) from intjoin t1 left join intjoin t2 on t1.i=t2.j \G *************************** 1. row…

Post: Is there a performance difference between JOIN and WHERE?

… to blog about the answer. “Is there a performance difference between putting the JOIN conditions in the ON clause or the WHERE… = B.ID; SELECT * FROM A JOIN B ON A.ID = B.ID; SELECT * FROM A JOIN B USING(ID); Personally, I prefer… from “comma joins” because a) the ANSI join syntax is more expressive and you’re going to use it anyway for LEFT JOIN, and…

Comment: Why MySQL could be slow with large tables ?

…does lot of counting. Does this look like a performance nightmare waiting to happen? Thanks, Will SELECT Q….JOIN tblanswersets ASets USING (answersetid) INNER JOIN tblanswersetsanswers_x ASAX USING (answersetid) INNER JOIN tblanswers A USING (answerid) LEFT JOIN (tblevalanswerresults e1 INNER JOIN

Comment: ORDER BY ... LIMIT Performance Optimization

… last 2 left joins affect considerably to the performance. Any idea how I can optimize this query? Thanks. SELECT * FROM message LEFT JOIN accounts a ON message_account = a.id LEFT JOIN

Post: MySQL VIEW as performance troublemaker

… keep queries simple without really thinking how it affects server performance. Even worse than that – looking at the short table which… users comments to the blog, naturally containing user_id which left comment, comment_id and comment text: CREATE TABLE `comments` ( `user… join” used to to join between them. In this particular case it is not that bad because “join cache” is used to perform it…

Comment: Why MySQL could be slow with large tables ?

… split the searchable data into two tables and did a LEFT JOIN to get the results. I noticed that when there were… and tested it with 35 million records with no performance problems. “Avoid LEFT JOIN if possible” is the best tip you could get…

Comment: Using delayed JOIN to optimize count(*) and LIMIT queries

… acts a little weard:P While this works when performing LEFT JOINS, with INNER JOINS it’s a different thing. Let’s say we… & 10000, like in the above example, but let’s perform an innerj join instead… The first subquery will return the requested 10…

Comment: Using delayed JOIN to optimize count(*) and LIMIT queries

… delayed JOIN to optimize count(*) and LIMIT queries… If you’re executing count(*) queries for such result sets MySQL will perform the join even if you use LEFT JOIN so it is not needed which slows down…

Post: Faster MySQL failover with SELECT mirroring

… passive master, too. Is that all? “Buffer pool warmed up, performance is better, case closed!” No. This isn’t as simple… to find the top tables on the active server and left-join those against the tables on the passive server, with both… write-only workload! The insert buffer can also cause terrible performance. There are some subtleties about exactly what’s happening that…