| ▲ | Why MySQL OR is slower than IN(percona.com) |
| 17 points by millspore 2 days ago | 6 comments |
| |
|
| ▲ | nathanfries an hour ago | parent | next [-] |
| Why can't consecutive OR statements with common columns be reduced to IN?
(I say consecutive since I assume ordering matters). WHERE id = 1 OR id = 2...
Should be abled to be reduced to
WHERE id IN (1,2...) However
WHERE id = 1 OR name = 'John' OR id = 2
Maybe can't be reduced to
WHERE id IN (1,2) OR name = 'John' |
| |
| ▲ | moring an hour ago | parent [-] | | Why does order of the OR operands matter? | | |
| ▲ | nathanfries an hour ago | parent | next [-] | | With a perfect optimizer and perfect knowledge of ordinality and statistics, I think performance would be the same. However in practice, I do not believe it always reorders predicates reliably for optimal performance. My experience is that order does matter in MySQL and especially in DWH environments where the optimizer may not be aware of things like partitioning. | | |
| ▲ | galkk a few seconds ago | parent [-] | | MySQL is an awful database server and shouldn’t be used as base for generalizations. |
| |
| ▲ | Riemer an hour ago | parent | prev [-] | | OR short-circuiting, evaluation stops when one of the statements is true. So it might influence performance? |
|
|
|
| ▲ | bot403 18 minutes ago | parent | prev [-] |
| I'm not going to trust any performance and tuning analysis that repeatedly quotes and graphs the runtime as seconds when it's measured in milliseconds. |