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

Не хватает индексов на shop_page #246

Open
Tri0L opened this issue Nov 14, 2017 · 0 comments
Open

Не хватает индексов на shop_page #246

Tri0L opened this issue Nov 14, 2017 · 0 comments

Comments

@Tri0L
Copy link
Contributor

Tri0L commented Nov 14, 2017

В логах базы много запросов вида:

SELECT id, full_url FROM shop_page WHERE (domain = 'S' AND route = 'S') AND (status = N)

при том что на таблице нет индексов по этим полям:

> SHOW INDEX FROM shop_page\G
 *************************** 1. row ***************************
        Table: shop_page
   Non_unique: 0
     Key_name: PRIMARY
 Seq_in_index: 1
  Column_name: id
    Collation: A
  Cardinality: 12037
     Sub_part: NULL
       Packed: NULL
         Null: 
   Index_type: BTREE
      Comment: 
Index_comment: 
1 row in set (0.00 sec)

По этому в ситуации:

> select count(*) from shop_page;
+----------+
| count(*) |
+----------+
|    12019 |
+----------+
1 row in set (0.00 sec)

Фуллскан выглядит очень печально:

# Query_time: 0.023135  Lock_time: 0.000159  Rows_sent: 20  Rows_examined: 12019
SET timestamp=1510639362;
SELECT id, full_url FROM shop_page WHERE (domain = 'example.com' AND route = '*') AND (status = 1);
> explain SELECT id, full_url FROM shop_page WHERE (domain = 'example.com' AND route = '*') AND (status = 1)\G
*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: shop_page
         type: ALL
possible_keys: NULL
          key: NULL
      key_len: NULL
          ref: NULL
         rows: 12037
        Extra: Using where
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant