Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Shouldn’t OR operations in an otherwise sargable[0] query just constitute merging two sargable queries? I don’t see why OR should affect the property

[0] new term for me, and wow do I not like it



This depends on the rdbms engine. Even if it might make sense, the planned could go with nested loops because of statistics and cost estimation.

In the article, the devil is in how the second explodes in size. We are suddenly cross-joining employees with customers. Left join of stores, employees and markouts gives you more than 2 rows. It gives you all the employees assigned to the store. Regardless only 2 have markouts.

Next, you join full customers table with it. And keep on multiplying the size by further left joining. Result size might quickly exceed the memory limits for efficient joins, and the rdbms might have to resort to poor nested loops.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: