Re: How do I avoid "Using file sort" and "Using temporary"
I did:
mysql> ANALYZE TABLE page_dim;
+---------------------------+---------+----------+----------+
| Table | Op | Msg_type | Msg_text |
+---------------------------+---------+----------+----------+
| core_dimensional.page_dim | analyze | status | OK |
+---------------------------+---------+----------+----------+
1 row in set (0.22 sec)
mysql> SHOW INDEX FROM page_dim;
+----------+------------+-----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+----------+------------+-----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| page_dim | 0 | PRIMARY | 1 | page_dim_id | A | 500 | NULL | NULL | | BTREE | |
| page_dim | 1 | page_type | 1 | page_type | A | 4 | NULL | NULL | | BTREE | |
+----------+------------+-----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
2 rows in set (0.03 sec)
However, the query is still slow and is still using "file sort" and "temporary". I wonder can it be because cardinality of page_type is only 4? (there are only four types of page in database currently).
If I replace the query with four separate queries, it looks more efficient way to do:
mysql> select sum(time_on_page) from page_view_fact pvf join page_dim pd on pvf.page_dim_id=pd.page_dim_id join registrant_selection rs on p
vf.registrant_dim_id=rs.registrant_dim_id and rs.report_id=87 where pd.page_type="Products Page";
+-------------------+
| sum(time_on_page) |
+-------------------+
| 104770 |
+-------------------+
1 row in set (0.28 sec)
mysql> select sum(time_on_page) from page_view_fact pvf join page_dim pd on pvf.page_dim_id=pd.page_dim_id join registrant_selection rs on p
vf.registrant_dim_id=rs.registrant_dim_id and rs.report_id=87 where pd.page_type="TouchPoint Portal";
+-------------------+
| sum(time_on_page) |
+-------------------+
| 116978 |
+-------------------+
1 row in set (0.28 sec)
mysql> select sum(time_on_page) from page_view_fact pvf join page_dim pd on pvf.page_dim_id=pd.page_dim_id join registrant_selection rs on p
vf.registrant_dim_id=rs.registrant_dim_id and rs.report_id=87 where pd.page_type="White Paper";
+-------------------+
| sum(time_on_page) |
+-------------------+
| 89591 |
+-------------------+
1 row in set (0.28 sec)
Thanks, Solon.
Subject
Views
Written By
Posted
32992
March 03, 2006 03:20PM
19900
March 04, 2006 11:46AM
18462
March 06, 2006 08:27AM
18300
March 06, 2006 10:16AM
Re: How do I avoid "Using file sort" and "Using temporary"
16551
March 06, 2006 12:51PM
18070
March 07, 2006 11:42AM
19801
March 10, 2006 03:01PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.