Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 1876

A database structure that can improve the speed of queries at the cost of disk space and slower inserts/updates. It stores a copy of one or more columns sorted but structures the data differently to allow faster access.

1 vote

Why is the candidate composite index not used?

INDEX(library_id, firstdateofinterval) will help the query run faster. Note that the column tested by = should be first and the range should be last. Why not use the desired index? … That is, all 4 of your indexes are equivalent to simply INDEX(firstdateofinterval) when you test for a range of dates. When you used the "index hint", did it actually run any faster? Unrelated... …
Rick James's user avatar
  • 79.4k
1 vote

Is "CREATE INDEX` in MySQL a Linear Operation?

Variable #1: If MySQL chooses to build the index(es) on the fly, or wait until all the data is in, then do a sort, etc, to build the index. … Manual splitting leads to unbalanced situations -- a table scan is stuck on the data disk; an index-only operation is stuck on the index disk; a lone query first hits the index disk, then the data disk …
Rick James's user avatar
  • 79.4k
1 vote

Hash index and where like clause

InnoDB, when building a secondary index (as with your name index), appends the columns of the PRIMARY KEY. This happens to make it a "covering index" (as indicated by "Using index"). …
Rick James's user avatar
  • 79.4k
1 vote

Why index is not used after replacing "WHERE field=x" to "field in (x,y)"?

The Optimizer looks at the situation as says (roughly): "If I need to scan more than 20% of the table, I won't bother using the index." … This is a reasonable decision because using an index requires bouncing between the index's BTree and the data's BTree. …
Rick James's user avatar
  • 79.4k
1 vote

index_merge not working in MariaDB

It is always better (as far as I know) to build a composite index: INDEX(id, flag) -- in either order If this is a 1-row table, then the effort of looking in two indexes to ultimately get a single … (But the answer will be the same -- use a composite index instead of hoping for "index merge intersect".) …
Rick James's user avatar
  • 79.4k
2 votes

What column/s do I need an index for my queries?

WHERE a op 3 -- usually can use INDEX(a) WHERE a = 3 ORDER BY b -- use INDEX(a,b), but WHERE a > 3 ORDER BY b -- won't get past the "range"; that is, INDEX(a,b) will work, but the b part will not be used … IN ( constants ) is somewhere between = and > for index-ability: WHERE a IN (constants) AND b > 8 might use both parts of INDEX(a,b), but WHERE a IN (constants) ORDER BY b cannot use both parts of INDEX
Rick James's user avatar
  • 79.4k
2 votes
Accepted

Are the index here will suffice to make the query faster?

(id), INDEX(category, date), INDEX(post_url), INDEX(user_url), INDEX(user_id, date), INDEX(msg_receiver_id, msg_sender_id, date) msg_table PRIMARY KEY(id), ?? … INDEX(msg_receiver_id, msg_status), INDEX(msg_url, date) …
Rick James's user avatar
  • 79.4k
1 vote

How to properly index a large table?

The way to approach indexing is to take each SELECT and decide what the optimal index is for that select. Be sure to consider "composite" indexes. … Be sure to avoid redundancies, such as: INDEX(a) is not needed if you have INDEX(a,b) INDEX(id) is not needed if you have PRIMARY KEY(id) If you get to more than, say, 10 indexes, then you should make …
Rick James's user avatar
  • 79.4k
3 votes
Accepted

Why mysql not using the index here?

Usually the Optimizer "does the right thing" in deciding between using the index (and bouncing between the index's BTree and the data BTree) versus simply scanning the entire table (and throwing out unwanted …
Rick James's user avatar
  • 79.4k
6 votes
Accepted

Does index need to cover all columns selected?

Long answer: A "covering" index is usually better than a non-covering one. A covering index for the query you mention would contain all the columns in the table. … If so, simply PRIMARY KEY(phone_number) is better than any "covering" index. Always provide SHOW CREATE TABLE when asking performance questions. …
Rick James's user avatar
  • 79.4k
1 vote

Index for date column along with multiple other columns in where clause

So add that index. As for INDEX(joining_date, ...) When using a 'range', that index will not get past joining_date to whatever other column(s) follow it. … So you may as say just INDEX(joining_date) As for the GROUP BY... Neither of your queries has any hope of using an index for the GROUP BY. …
Rick James's user avatar
  • 79.4k
0 votes

mysql 5.5 compound index order

If it is no more than those 3 columns, then a "covering" index will be a slight benefit: INDEX(ot_id, numval1, numval2) INDEX(ot_id, numval2, numval1) Again, this leaves it to the Optimizer to dynamically … Again it leads to 2 choices: INDEX(numval1) INDEX(numval2) Or, if covering: INDEX(numval1, numval2, ot_id) INDEX(numval2, numval1, ot_id) (The last pair of columns can be in either order.) …
Rick James's user avatar
  • 79.4k
1 vote
Accepted

Mysql - index - optimization (two separate or a multikey)

Then you need INDEX(id, date) INDEX(id, type, -- in either order date) No single index handles both queries equally well. … (Based on your Comments) If (id, date) is unique, then make that the PK. and toss the other index. If (id, type, date) is unique, make it the PK and toss the other index. …
Rick James's user avatar
  • 79.4k
1 vote

Is there a situation where MySQL creates a nonclustered index automatically?

A UNIQUE key is an INDEX, plus a uniqueness constraint. (Note: may be clustered) An INDEX is a BTree that is used for efficient access. … A FOREIGN key creates an INDEX if there is not already a suitable index. (Note: Non-clustered) The 3 "Notes" are implicitly-created indexes, but not necessarily non-clustered. …
Rick James's user avatar
  • 79.4k
1 vote

Why does MariaDB choose different index use for the same data?

Run CHECK TABLE logs; -- the index may be corrupted. (This is a MyISAM-only thing to do.) Use InnoDB, not MyISAM. …
Rick James's user avatar
  • 79.4k

1
2 3 4 5
25
15 30 50 per page