Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing order of WHERE params changes performance dramaticaly #1645

Open
starinacool opened this issue Nov 30, 2023 · 1 comment
Open

Changing order of WHERE params changes performance dramaticaly #1645

starinacool opened this issue Nov 30, 2023 · 1 comment
Assignees
Labels
bug est::size_S waiting Waiting for the original poster (in most cases) or something else

Comments

@starinacool
Copy link

starinacool commented Nov 30, 2023

Describe the bug
Query performance depend on WHERE parameters order

To Reproduce
Steps to reproduce the behavior:

  1. Run queries changing order of params

Expected behavior
Performance does not depend on params order

Describe the environment:
Manticore 6.2.12 dc5144d@230822
Linux manticore-002 6.1.0-13-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.55-1 (2023-09-29) x86_64 GNU/Linux

Messages from log files:
Messages from searchd.log and query.log (if applicable).

Additional context

select id,name from listing2 where is_reposted=0 and salesman=361813 and beg_date>1701251485 ORDER by name asc LIMIT 0,1000 OPTION ranker=none, cutoff=10000, retry_count=5, retry_delay=100, max_predicted_time=10, max_matches=1000; SHOW META;

Empty set (0.033 sec)

+---------------------+------------------------------------------------------------------+
| Variable_name       | Value                                                            |
+---------------------+------------------------------------------------------------------+
| total               | 0                                                                |
| total_found         | 0                                                                |
| total_relation      | eq                                                               |
| time                | 0.032                                                            |
| local_fetched_docs  | 0                                                                |
| local_fetched_hits  | 0                                                                |
| local_fetched_skips | 0                                                                |
| predicted_time      | 0                                                                |
| index               | is_reposted:SecondaryIndex (100%), salesman:SecondaryIndex (20%) |
+---------------------+------------------------------------------------------------------+

Now lets put salesman to the front of WHERE section:

select id,name from listing2 where salesman=361813 and is_reposted=0 and beg_date>1701251485 ORDER by name asc LIMIT 0,1000 OPTION ranker=none, cutoff=10000, retry_count=5, retry_delay=100, max_predicted_time=10, max_matches=1000; SHOW META;

+---------------------+------------------------------------------------------------------+
| Variable_name       | Value                                                            |
+---------------------+------------------------------------------------------------------+
| total               | 0                                                                |
| total_found         | 0                                                                |
| total_relation      | eq                                                               |
| time                | 0.003                                                            |
| local_fetched_docs  | 0                                                                |
| local_fetched_hits  | 0                                                                |
| local_fetched_skips | 0                                                                |
| predicted_time      | 0                                                                |
| index               | salesman:SecondaryIndex (100%), is_reposted:SecondaryIndex (20%) |
+---------------------+------------------------------------------------------------------+

salesman attribute has much higher cardinality.

@glookka
Copy link
Contributor

glookka commented Jul 4, 2024

Please provide index or source data that we can use to reproduce this behavior.

@glookka glookka added the waiting Waiting for the original poster (in most cases) or something else label Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug est::size_S waiting Waiting for the original poster (in most cases) or something else
Projects
None yet
Development

No branches or pull requests

3 participants