Questions tagged [indexing]

Indexing data structures is a general technique to improve the speed of data lookups.

The purpose of storing an index is to optimize speed and performance in finding relevant documents for a search query. Without an index, the search process would scan every document in the corpus, which would require considerable time and computing power.

Indexes may benefit both read queries and updates. Many people wrongly believe indexes are only good for read queries. In general, there are three methods of indexing - non-clustered, clustered and cluster.

References:

Top Indexing Questions

By these questions, you will clear your concepts regarding indexing. And you can ask similar questions (not duplicate) with this tag.

33955 questions
362
votes
19 answers

How can I remove an element from a list?

I have a list and I want to remove a single element from it. How can I do this? I've tried looking up what I think the obvious names for this function would be in the reference manual and I haven't found anything appropriate.
David Locke
  • 17,926
  • 9
  • 33
  • 53
337
votes
11 answers

Access multiple elements of list knowing their index

I need to choose some elements from the given list, knowing their index. Let say I would like to create a new list, which contains element with index 1, 2, 5, from given list [-2, 1, 5, 3, 8, 5, 6]. What I did is: a = [-2,1,5,3,8,5,6] b = [1,2,5] c…
hoang tran
  • 3,918
  • 3
  • 19
  • 21
315
votes
6 answers

Disable intellij indexing on specific folder

In my project I have .deploy folder which is created/updated when I deploy my app locally. Is it possible to disable indexing on that folder? Everything slows down whenever I deploy and it's really annoying - I have to wait a few minutes whilist…
Marcin Szymaniuk
  • 3,579
  • 2
  • 19
  • 15
311
votes
8 answers

Does MySQL index foreign key columns automatically?

Does MySQL index foreign key columns automatically?
Dónal
  • 185,044
  • 174
  • 569
  • 824
307
votes
13 answers

What are the differences between a clustered and a non-clustered index?

What are the differences between a clustered and a non-clustered index?
Eric Labashosky
  • 29,484
  • 14
  • 39
  • 32
293
votes
9 answers

Difference between Key, Primary Key, Unique Key and Index in MySQL

When should I use KEY, PRIMARY KEY, UNIQUE KEY and INDEX?
HELP
  • 14,237
  • 22
  • 66
  • 100
291
votes
16 answers

How to get indices of a sorted array in Python

I have a numerical list: myList = [1, 2, 3, 100, 5] Now if I sort this list to obtain [1, 2, 3, 5, 100]. What I want is the indices of the elements from the original list in the sorted order i.e. [0, 1, 2, 4, 3] --- ala MATLAB's sort function…
Gyan
  • 2,919
  • 2
  • 15
  • 3
278
votes
24 answers

List columns with indexes in PostgreSQL

I would like to get the columns that an index is on in PostgreSQL. In MySQL you can use SHOW INDEXES FOR table and look at the Column_name column. mysql> show indexes from…
Luke Francl
  • 31,028
  • 18
  • 69
  • 91
276
votes
16 answers

C++ sorting and keeping track of indexes

Using C++, and hopefully the standard library, I want to sort a sequence of samples in ascending order, but I also want to remember the original indexes of the new samples. For example, I have a set, or vector, or matrix of samples A : [5, 2, 1, 4,…
Mingus
  • 2,903
  • 3
  • 18
  • 9
272
votes
9 answers

Is the primary key automatically indexed in MySQL?

Do you need to explicitly create an index, or is it implicit when defining the primary key? Is the answer the same for MyISAM and InnoDB?
Alex Miller
  • 69,183
  • 25
  • 122
  • 167
268
votes
4 answers

Can I add a UNIQUE constraint to a PostgreSQL table, after it's already created?

I have the following table: tickername | tickerbbname | tickertype ------------+---------------+------------ USDZAR | USDZAR Curncy | C EURCZK | EURCZK Curncy | C EURPLN | EURPLN Curncy | C USDBRL | USDBRL Curncy | C USDTRY …
Thomas Browne
  • 23,824
  • 32
  • 78
  • 121
258
votes
10 answers

Postgres unique constraint vs index

As I can understand documentation the following definitions are equivalent: create table foo ( id serial primary key, code integer, label text, constraint foo_uq unique (code, label)); create table foo ( id serial primary key, …
Adam Piotrowski
  • 2,945
  • 3
  • 20
  • 23
245
votes
5 answers

What's the difference between using INDEX vs KEY in MySQL?

I know how to use INDEX as in the following code. And I know how to use foreign key and primary key. CREATE TABLE tasks ( task_id int unsigned NOT NULL AUTO_INCREMENT, parent_id int unsigned NOT NULL DEFAULT 0, task …
shin
  • 31,901
  • 69
  • 184
  • 271
244
votes
7 answers

MySQL indexes - what are the best practices?

I've been using indexes on my MySQL databases for a while now but never properly learnt about them. Generally I put an index on any fields that I will be searching or selecting using a WHERE clause but sometimes it doesn't seem so black and…
Haroldo
  • 36,607
  • 46
  • 127
  • 169
239
votes
5 answers

pandas: multiple conditions while indexing data frame - unexpected behavior

I am filtering rows in a dataframe by values in two columns. For some reason the OR operator behaves like I would expect AND operator to behave and vice versa. My test code: df = pd.DataFrame({'a': range(5), 'b': range(5) }) # let's insert some -1…
Wojciech Walczak
  • 3,419
  • 2
  • 23
  • 24