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
19
votes
4 answers

Creating Indexes on DB with Hibernate @Index Annotation

I have annotation-driven hibernate capabilies on my project. Now I want to create an index over a column. My current column definition is @NotNull @Column(name = "hash") private String hash; and I add @Index annotation here. @NotNull @Column(name =…
19
votes
7 answers

Do I need to add an Index on ORDER BY field?

I have a query of such like $query = "SELECT * FROM tbl_comments WHERE id=222 ORDER BY comment_time"; Do I need to add an index on the comment_time field? Also, if I want to get the data between two dates then how should I build the index?
Munib
  • 2,995
  • 7
  • 24
  • 35
16
votes
1 answer

Deferrable, case-insensitive unique constraint

Is it possible in PostgreSQL to create a deferrable unique constraint on a character column, but case-insensitive? Let's assume the following basic table: CREATE TABLE sample_table ( my_column VARCHAR(100) ); If deferrable constraint is not…
Code Painters
  • 6,757
  • 2
  • 27
  • 46
15
votes
1 answer

SQL Server Web vs Standard edition

I have found out that there's two versions of SQL Server types that are very different in terms of pricing... The Web version from my host provider costs about 13$ per 2 core packs, whereas the Standard edition is right around 200$. From my…
User987
  • 3,273
  • 10
  • 38
  • 85
15
votes
1 answer

How to implement composite primary keys in rails

I have a User model that looks like this: class User < ApplicationRecord belongs_to :organization belongs_to :department end The users table in the database has the two foreign keys organization_id and department_id. How can I make these two…
Mark
  • 3,488
  • 4
  • 21
  • 42
10
votes
1 answer

Indexes on join tables

When searching on Google for join table indexes, I got this question. Now, I believe that it is giving some false information in the accepted answer, or I do not understand how everything works. Given the following tables (running on PostGreSQL…
Florin Asăvoaie
  • 755
  • 1
  • 5
  • 19
10
votes
2 answers

Why MongoDB doesn't use Index Intersection?

I am trying to reproduce the first example of index intersection instruction (http://docs.mongodb.org/manual/core/index-intersection/) but facing a problem: mongo doesn't uses both indexes My steps: Download mongo (3.0.3) and install it Run mongod:…
Alexander
  • 542
  • 2
  • 14
10
votes
5 answers

SQL Server - INSERT failed because of 'ARITHABORT'

I use NHibernate and SQL Server 2005 and I have an index on a computed column in one of my tables. My problem is that when I insert a record to that table I get the following error: INSERT failed because the following SET options have incorrect…
9
votes
1 answer

How do I change a column from null to not null when an index depends on that column without recreating the index?

I have a column Column which is declared to be NULL DEFAULT(GETUTCDATE()) and there's a non-clustered index that includes this column. I want to change this column to be NOT NULL DEFAULT(GETUTCDATE()) and when I run ALTER TABLE ALTER COLUMN…
sharptooth
  • 159,303
  • 82
  • 478
  • 911
8
votes
4 answers

Different types of database indexes?

I am trying to compile a list of non-system-specific database indexes. I've looked at Oracle, DB2, MySQL, Postgres and Sybase, and almost every resource has a different list. So far I have seen: clustered, multi-dimensional clustered, unclustered,…
Nathron
  • 1,462
  • 1
  • 16
  • 22
8
votes
1 answer

Row level security(RLS) performance is significantly slower in postgres.

Description : Here is the sample demonstration of the performance issue. We first created two tables , enabled row level security and created policy as well . Table definition: create table sample_schema.sample_table1(ID numeric(38) PRIMARY KEY NOT…
8
votes
4 answers

Cannot remove an index from table in Rails 4 and PSQL 9.3

In my schema.rb I have the following line: add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree When I run \di in psql I get: Schema | Name | Type | Owner |…
Alexander
  • 17,699
  • 19
  • 72
  • 107
8
votes
1 answer

MySQL query by date with big inverval

I have big table with 22 millions records. I want to execute next query: select auto_alerts from alerts_stat where endDate > "2012-12-01" To improve performance I added BTREE index for endData field: CREATE INDEX endDate_index USING BTREE ON…
Taky
  • 5,076
  • 1
  • 16
  • 28
7
votes
3 answers

How binary search is used in database indexing

I know how binary search works but I wanted to know practical uses for binary search... I searched through the internet and I found that the main use is data base indexing, but I couldn't understand how binary search could help in data base…
7
votes
1 answer

MySQL Optimization: EXPLAIN "Extra" column contains "Using Where"

So I always thought that seeing "Using Where" in the Extra column was a good thing. However, I was planning a brown bag lunch for my coworkers on intepreting EXPLAIN and now I'm not so sure. The MySQL doc says this in the notes about "Using…
Mike Sherov
  • 12,634
  • 7
  • 38
  • 62
1
2
3
31 32