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
9
votes
7 answers

Determining if MySQL table index exists before creating

Our system's automated database migration process involves running .sql scripts containing new table definitions and their accompanying indexes. I require the ability to create these tables and indexes only if they don't already exist. Tables are…
NeilInglis
  • 3,431
  • 4
  • 30
  • 31
9
votes
2 answers

Optimal Postgres text index for LIKE query?

Using Postgres 9.5, I have a table addresses. CREATE TABLE addresses ( id integer PRIMARY KEY, address text ); In that table I have 7.5 million rows. Example: 1, "1600 Pennsylvania Avenue NW, Washington, DC, 20500" I'm using this…
Tyler
  • 161
  • 1
  • 11
9
votes
6 answers

Fastest way to find Indexes of item in list?

If one was to attempt to find the indexes of an item in a list you could do it a couple different ways here is what I know to be the fastest: aList = [123, 'xyz', 'zara','xyz', 'abc']; indices = [i for i, x in enumerate(aList) if x ==…
Tyler Cowan
  • 820
  • 4
  • 13
  • 35
9
votes
2 answers

Setting NA in a matrix using another logical matrix

I just saw what seemed like a perfectly good question that was deleted and since like the original questioner I couldn't find a duplicate, I'm posting again. Assume that I have a simple matrix ("m"), which I want to index with another logical matrix…
IRTFM
  • 258,963
  • 21
  • 364
  • 487
9
votes
3 answers

Azure CDN default document index.html

I have now successfully setup my static website in a CDN, Is there a way to specify that index.html is the default document ? It is a 1 page site I just would like to browse to the root url without having to type /index.html .. Thank you
fran6
  • 341
  • 1
  • 4
  • 14
9
votes
2 answers

Index a numpy array with another array

I feel silly, because this is such a simple thing, but I haven't found the answer either here or anywhere else. Is there no straightforward way of indexing a numpy array with another? Say I have a 2D array >> A = np.asarray([[1, 2], [3, 4], [5, 6],…
Dugas
  • 381
  • 1
  • 3
  • 9
9
votes
1 answer

How to use index in foreign table SELECT MAX(id) query in PostgreSQL?

I've got a foreign table (using postgresql_fdw foreign data wrapper) and I need to find maximum ID to copy all records. When I run SELECT MAX(id) FROM foreign_table it doesn't seem to be using index: Aggregate (cost=205.06..205.07 rows=1 width=4)…
9
votes
1 answer

How does SQL Server treat indexes on a table behind a view?

So I'm trying to understand how SQL Server makes use of indexes on tables behind views. Here's the scenario: Table A has a composite clustered index on fields 1 & 2 and a nonclustered index on fields 3 & 4. View A is written against Table A to…
Mike Fal
  • 1,196
  • 11
  • 18
9
votes
5 answers

Effects of Clustered Index on DB Performance

I recently became involved with a new software project which uses SQL Server 2000 for its data storage. In reviewing the project, I discovered that one of the main tables uses a clustered index on its primary key which consists of four…
Avalanchis
  • 4,500
  • 3
  • 39
  • 48
9
votes
4 answers

MySQL indexes - what are the best practices according to this table and queries

i have this table (500,000 row) CREATE TABLE IF NOT EXISTS `listings` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `type` tinyint(1) NOT NULL DEFAULT '1', `hash` char(32) NOT NULL, `source_id` int(10) unsigned NOT NULL, `link`…
Mostafa Elkady
  • 5,645
  • 10
  • 45
  • 69
9
votes
2 answers

removing the name of a pandas dataframe index after appending a total row to a dataframe

I have calculated a series of totals tips by day of a week and appended it to the bottom of totalspt dataframe. I have set the index.name for the totalspt dataframe to None. However while the dataframe is displaying the default 0,1,2,3 index it…
yoshiserry
  • 20,175
  • 35
  • 77
  • 104
9
votes
3 answers

Rails Postgres functional indexes

How I should enter my multicolum indexes which contain functions into schema.rb ? for example this DOESN'T work: add_index "temporary_events", ["templateinfoid", "campaign", "date(gw_out_time)", "messagetype"], :name =>…
astropanic
  • 10,800
  • 19
  • 72
  • 132
9
votes
2 answers

Writing to Lucene index, one document at a time, slows down over time

We have a program, which runs continually, does various things, and changes some records in our database. Those records are indexed using Lucene. So each time we change an entity we do something like: open db transaction, open Lucene IndexWriter…
Adrian Smith
  • 17,236
  • 11
  • 71
  • 93
9
votes
2 answers

Function of deferred join in MySQL

I am reading High performance MySQL and I am a little confused about deferred join. The book says that the following operation cannot be optimized by index(sex, rating) because the high offset requires them to spend most of their time scanning a lot…
user1659464
  • 313
  • 1
  • 3
  • 9
9
votes
1 answer

R - How to re-order row index number

Simply put, I have the following data frame: Signal 4 9998 3 549 1 18 5 2.342 2 0.043 and I want to reset the index numbers to be like : Signal 1 9998 2 549 3 18 4 2.342 5 …
mtleis
  • 712
  • 1
  • 9
  • 28