Questions tagged [database-indexes]

An index contains keys built from one or more columns in the table, or view, and pointers that map to the storage location of the specified data.

An index contains keys built from one or more columns in the table, or view, and pointers that map to the storage location of the specified data.

References:

Top Questions related to Database Indexing

474 questions
2573
votes
8 answers

How does database indexing work?

Given that indexing is so important as your data set increases in size, can someone explain how indexing works at a database-agnostic level? For information on queries to index a field, check out How do I index a database column.
Xenph Yan
  • 76,635
  • 15
  • 45
  • 54
120
votes
3 answers

PostgreSQL: Can you create an index in the CREATE TABLE definition?

I want to add indexes to some of the columns in a table on creation. Is there are way to add them to the CREATE TABLE definition or do I have to add them afterward with another query? CREATE INDEX reply_user_id ON reply USING btree (user_id);
Xeoncross
  • 50,836
  • 73
  • 238
  • 351
101
votes
6 answers

A list of indices in MongoDB?

Is there a way to see a list of indices on a collection in mongodb in shell? i read through http://www.mongodb.org/display/DOCS/Indexes but i dont see anything
Timmy
  • 11,360
  • 18
  • 66
  • 104
64
votes
1 answer

Does rename_column take care of indexes?

Say, we have something like this: add_column :users, :single, :boolean add_index :users, :single and then later we do rename_column :users, :single, :married Will ActiveRecord and/or the database handle the renaming of the index as well or do I…
56
votes
4 answers

Can MySQL use multiple indexes for a single query?

Imagine a table with multiple columns, say, id, a, b, c, d, e. I usually select by id, however, there are multiple queries in the client app that uses various conditions over subsets of the columns. When MySQL executes a query on a single table with…
kolypto
  • 23,092
  • 13
  • 75
  • 76
31
votes
1 answer

PostgreSQL: Create index for boolean column

I have a table that has one boolean column. productid integer isactive boolean When I execute the query SELECT productid FROM product WHERE ispublish LIMIT 15 OFFSET 0 After that, I created an index for the ispublish…
Văn Duy Nguyễn
  • 311
  • 1
  • 3
  • 3
31
votes
5 answers

Advantage of BTREE?

I create indexes without the USING BTREE clause. Is there any advantage of using BTREE index? CREATE INDEX `SomeName` USING BTREE ON `tbl_Name`(`column_name`);
shantanuo
  • 27,732
  • 66
  • 204
  • 340
29
votes
1 answer

Why are super columns in Cassandra no longer favoured?

I have read in the latest release that super columns are not desirable due to "performance issues", but no where is this explained. Then I read articles such as this one that give wonderful indexing patterns using super columns. This leave me with…
IamIC
  • 16,207
  • 18
  • 81
  • 142
27
votes
3 answers

Multiple indexes vs single index on multiple columns in postgresql

I could not reach any conclusive answers reading some of the existing posts on this topic. I have certain data at 100 locations the for past 10 years. The table has about 800 million rows. I need to primarily generate yearly statistics for each…
let_there_be_light
  • 497
  • 3
  • 6
  • 14
26
votes
5 answers

Django: Does unique_together imply db_index=True in the same way that ForeignKey does?

A field on a model, foo = models.ForeignKey(Foo) will automatically add a database index for the column, in order to make look-ups faster. That's good and well, but Django's docs don't state whether the fields in a model-meta's unique_together…
orokusaki
  • 48,267
  • 47
  • 159
  • 244
25
votes
2 answers

Postgres not using index when index scan is much better option

I have a simple query to join two tables that's being really slow. I found out that the query plan does a seq scan on the large table email_activities (~10m rows) while I think using indexes doing nested loops will actually be faster. I rewrote the…
Ryan Her
  • 857
  • 1
  • 6
  • 13
25
votes
3 answers

Cassandra: choosing a Partition Key

I'm undecided whether it's better, performance-wise, to use a very commonly shared column value (like Country) as partition key for a compound primary key or a rather unique column value (like Last_Name). Looking at Cassandra 1.2's documentation…
25
votes
3 answers

Neo4j: Step by Step to create an automatic index

I am creating a new Neo4j database. I have a type of node called User and I would like an index on the properties of user Identifier and EmailAddress. How does one go setting up an index when the database is new? I have noticed in the…
Aran Mulholland
  • 22,728
  • 23
  • 129
  • 222
24
votes
2 answers

How do I know when to index a column, and with what?

In docs for various ORMs they always provide a way to create indexes, etc. They always mention to be sure to create the appropriate indexes for efficiency, as if that is inherent knowledge to a non-hand-written-SQLer who needs to use an ORM. My…
orokusaki
  • 48,267
  • 47
  • 159
  • 244
21
votes
3 answers

Indexes with included columns, what's the difference?

I've never really understood the difference between these two indexes, can someone please explain what the difference is (performance-wise, how the index structure will look like in db, storage-wise etc)? Included index CREATE NONCLUSTERED INDEX…
dadde
  • 616
  • 1
  • 10
  • 23
1
2 3
31 32