clustered-index

Does clustered index on foreign key column increase join performance vs non-clustered ?

In many places it's recommended that clustered indexes are better utilized when used to select range of rows using BETWEEN statement. When I select joining by foreign key field in such a way that this clustered index is used, I guess, that clusterization should help too because range of rows is being selected even though they all have sa...

Can you contrive a simple example in MySQL where clustered index is the solution, instead of normal index?

I don't see the point of clustered index, when will we benefit? ...

Should searchable date fields in a database table always be indexed?

If I have a field in a table of some date type and I know that I will always be searching it using comparisons like between, > or < and never = could there be a good reason not to add an index for it? ...

How to change the primary key to be non-clustered?

Part-time reluctant DBA here. I want to change an existing primary key index from clustered to non-clustered. And the syntax is escaping me. This is how it's scripted out right now. ALTER TABLE [dbo].[Config] WITH NOCHECK ADD CONSTRAINT [PK_Config] PRIMARY KEY CLUSTERED ( [ConfigID] ) ON [PRIMARY] I am not...

SQL Server database with clustered GUID PKs - switch clustered index or switch to sequential (comb) GUIDs?

We have a database in which all the PKs are GUIDs, and most of the PKs are also the clustered index for the table. We know that this is bad (due to the random nature of GUIDs). So, it seems there are basically two options here (short of throwing out GUIDs as PKs altogether, which we cannot do (at least not at this time)). We could chan...

Creating NONCLUSTERED INDEX on column by convention or fluent map

Hi, I want to use schemaExport to generate my Database. So, I would like some help as one of my table needs to have a non-clustered index on one column. Is there any way I can use the IIndexConvention to implement it? I could use a custom attribute to distinguee the property and then apply the convention for example. Many thanks. ...

SQL Server: Clustering by timestamp; pros/cons

I have a table in SQL Server, where i want inserts to be added to the end of the table (as opposed to a clustering key that would cause them to be inserted in the middle). This means I want the table clustered by some column that will constantly increase. This could be achieved by clustering on a datetime column: CREATE TABLE Things ( ...

In SQL, in what situation do we want to Index a field in a table, or 2 fields in a table at the same time?

In SQL, it is obvious that whenever we want to do a search on millions of record, say CustomerID in a Transactios table, then we want to add an index for CustomerID. Is another situation we want to add an index to a field when we need to do inner join or outer join using that field as a criteria? Such as Inner join on t1.custumerID = t...

SQL Server Clustered Index: (Physical) Data Page Order

I am struggling understanding what a clustered index in SQL Server 2005 is. I read the MSDN article Clustered Index Structures (among other things) but I am still unsure if I understand it correctly. The (main) question is: what happens if I insert a row (with a "low" key) into a table with a clustered index? The above mentioned MSDN a...

Is it bad to have a non-clustered index that contains the primary key from the clustered index?

If you have a table with a clustered index on the Primary Key (int), is it redundant and bad to have one (ore more) non-clustered indexes that include that primary key column as one of the columns in the non-clustered index? ...

Covering Index versus Clustered Index (Database Index)

Hi, I'm working on a database system and it's indexes, but I'm having a really hard time seing the clear difference between a covering index and a clustered index. I've googled my way around but hasn't got a clear cut answer on: What is the differences between the two types of indexes When do I use Covering index and when do I use Cl...

Database: Help me with correct index(es) for a table and query

Hi, I am running some queries in my database and want to increase the performance and have created some indexes but I still think that the response time is to great so I want to see if I can create a better or another index to increase the speed. My schema for the table I think has the biggest bottleneck look like this: R_D( **id** i...

Clustered index - multi-part vs single-part index and effects of inserts/deletes

This question is about what happens with the reorganizing of data in a clustered index when an insert is done. I assume that it should be more expensive to do inserts on a table which has a clustered index than one that does not because reorganizing the data in a clustered index involves changing the physical layout of the data on the di...

Moving from a non-clustered PK to a clustered PK in SQL 2005

HI all, I recently asked this question in another thread, but was told it would be better to move it to a new question instead. What if I have an auto-increment INT as my non-clustered primary key, and there are about 15 foreign keys defined to it ? (snide comment about original designer being braindead in the original :) ) This...

customer.pk_name joining transactions.fk_name vs. customer.pk_id [serial] joining transactions.fk_id [integer]

Pawnshop Application (any RDBMS): one-to-many relationship where each customer (master) can have many transactions (detail). customer( id serial, pk_name char(30), {PATERNAL-NAME MATERNAL-NAME, FIRST-NAME MIDDLE-NAME-INITIAL} [...] ); unique index on id; unique cluster index on pk_name; transaction( fk_name char(30), tran_type char(1...

Searching table by Guid faster when the Guid is the clustered index?

If I am going to be querying a table by Guids (irregardless of fragmentation problems with Guids), would it be faster to have the Guid as the clustered index rather than the non-clustered index or no index at all? This question is coming from a read-only standpoint. I'm just curious if there will be a speed improvement between the searc...

Setting indexed columns on a custom SQL table

Hi, I've read about primary, unique, clustered indexes etc. But I need to understand it via an example. The image below is the auto-generated aspnet_Users table captured from SQL Server Web Admin Panel. Taking this as a model; I will create a custom table called Companies and let's say the fields are: ID, Name, ShortName, Address,...

H2 database: clustered indexes support

I use H2 database for environmental data which contains lots of time series. Time series are simply measurement values of sensors which are recorded in database periodically (say once per hour). The data stored in the table: CREATE TABLE hydr (dt timestamp ,value double ,sensorid int) I would like to make range queries against the t...

How to drop clustered property but retain primary key in a table. SQL Server 2005

i have the following key: ALTER TABLE dbo.Table ADD CONSTRAINT PK_ID PRIMARY KEY CLUSTERED ( ID ASC ) so i have clustered index and primary key on ID column. Now i need to drop clustered index (i want to create new clustered index on another column), but retain primary key. Is it possible? ...

Is a CLUSTER INDEX desireable when loading a sorted loadfile into a new table?

INFORMIX-SE: My users periodically run an SQL script [REORG.SQL] which unloads all rows from a table in sorted order to two separate files (actives and inactives), drops the table, re-creates the table, loads the sorted loadfiles back into it, creates a cluster index on the same column I sorted my unload files by, creates other supporti...