2
votes
1answer
25 views

Making MySQL use primary index without hinting or forcing

I have the following db structure: CREATE TABLE `question` ( `id` int(11) NOT NULL AUTO_INCREMENT, `level_id` int(11) NOT NULL, `video_id` int(11) NOT NULL, `is_active` tinyint(1) NOT NULL, ...
0
votes
0answers
167 views

Using an enum as part of an index definition

When I use an ENUM column in a table the ORDER BY uses the ordinal of the ENUM not its value. I wasn't aware of that. So my question is what are the subtle issues when an ENUM is part of an index ...
0
votes
2answers
48 views

same field in bothe “where” and “order by” - how to index for this query?

The query: EXPLAIN EXTENDED SELECT *, u.user_id FROM xgate_geoloc g JOIN tig_users u ON g.uid = u.uid WHERE -- corners selection: ( ( ...
2
votes
2answers
2k views

MySQL not using indexes when joining against another table

I have two tables, the first table contains all articles / blog posts within a CMS. Some of these articles may also appear in a magazine, in which case they have a foreign key relationship with ...
0
votes
1answer
282 views

Postgresql table with one integer column, sorted index, with duplicate primary key

I want to have a table in PostgreSQL with these properties: One column with an integer Allow duplicates in this column. Duplicates will be rare. Duplicates have no meaning logically and will be ...
1
vote
4answers
433 views

MySql Order by isnull() Performance Problem

my sql below is use for listing stock added from 10 days ago. Order by isnull(Price) is use so that stock without any price yet will still being listed. AddDate and Price has an index. SELECT Id, ...
0
votes
1answer
49 views

Index on a query with order

I have the following table with >1M rows: CREATE TABLE `wishlist_place` ( `id` int(11) NOT NULL AUTO_INCREMENT, `wishlist_id` int(11) DEFAULT NULL, `place_id` int(11) DEFAULT NULL, `city_id` ...
1
vote
1answer
905 views

db INDEX on ORDER BY FIELD in very simple query does not help - still slow response?

I have very simple query which returns 200K records very slow (20 seconds). SELECT * FROM TABLE ORDER BY ID DESC If I do just SELECT * FROM TABLE it returns quick result. I created INDEX on ...
8
votes
2answers
997 views

Must an index cover all selected columns for it to be used for ORDER BY?

Over at SO, someone recently asked Why isn't ORDER BY using the index? The situation involved a simple InnoDB table in MySQL comprising three columns and 10k rows. One of the columns, an integer, ...
0
votes
1answer
56 views

Is index like key(timetime) usable when we query: SELECT * … ORDER BY timetime DESC

When we index a timestamp field like timetime. Can we use it for ORDER BY timetime DESC or is it just usable for ORDER BY timetime ASC OR ORDER BY timetime? Does mySQL use this index when doing vise ...
10
votes
1answer
5k views

Order by column should have index or not?

I have added indexes to table which are used for searching result. I am showing results by ASC or DESC order. So that column should have index or not? I have 2 more indexes on that table. How ...