indexing

How do you disable all table indexes in sql server compact edition via an SqlCeCommand Object?

I'm trying to do a huge bulk insert into an SqlCe database (version 3.5, oh and using C# 3). I've tried various ways of doing this (table adapter insert, a prepared parameterized query, sqlceresultset insert etc.). The fastest time, as I've read on many sites, was using the SqlCeResultSet object, in table direct mode. I want to speed th...

How to properly index a linking table for many-to-many connection in MySQL?

Lets say I have a simple many-to-many table between tables "table1" and "table2" that consists from two int fields: "table1-id" and "table2-id". How should I index this linking table? I used to just make a composite primary index (table1-id,table2-id), but I read that this index might not work if you change order of the fields in the qu...

Set up Oracle Text to index values of multiple columns in Oracle tables

I have a set of Oracle tables that describe information about property owners. Owner names and other text values are stored in multiple fields in multiple related tables, for each owner. I would like to index the contents of these fields. My goal is to provide a single field where a user can enter keywords to locate owners. How do I set...

Where to place a primary key

To my knowledge SQL Server 2008 will only allow one clustered index per table. For the sake of this question let's say I have a list of user-submitted stories that contains the following columns. ID (int, primary key) Title (nvarchar) Url (nvarchar) UniqueName (nvarchar) This is the url slug (blah-blah-blah) CategoryID (int, FK to Cate...

Query to fetch MsSQL table unique index and primary keys

SELECT sysobjects.xtype, syscolumns.name, sysindexkeys.indid, sysobjects.type FROM syscolumns LEFT JOIN sysobjects ON syscolumns.id = sysobjects.id LEFT JOIN sysindexkeys ON ( syscolumns.id = sysindexkeys.id AND syscolumns.colid = sysindexkeys.colid ) WHERE sysobjects.name = '{$table}' AND sysindexkeys.indid IS NOT NULL ORDER BY...

indexes in mysql SELECT AS or using Views

I'm in over my head with a big mysql query (mysql 5.0), and i'm hoping somebody here can help. Earlier I asked how to get distinct values from a joined query http://stackoverflow.com/questions/508707/mysql-count-only-for-distinct-values-in-joined-query The response I got worked (using a subquery with join as) select * from media m i...

Is primary key always clustered?

Hi, Please clear my doubt about this, In SQL Server (2000 and above) is primary key automatically cluster indexed or do we have choice to have non-clustered index on primary key? ...

Do all SQL server versions rebuild indexes automatically or have a default rebuild criteria?

Do all SQL server versions rebuild indexes automatically or have a default rebuild criteria? I understand statistics are rebuilt automatically but not sure if indexes do as well. ...

Index Seek with Bookmark Lookup Only Option for SQL Query?

I am working on optimizing a SQL query that goes against a very wide table in a legacy system. I am not able to narrow the table at this point for various reasons. My query is running slowly because it does an Index Seek on an Index I've created, and then uses a Bookmark Lookup to find the additional columns it needs that do not exist ...

DB2 multiple column index issue

If I have a multiple column index(a,b,c) and one separate index d then my query is using b,a,c,d order whether both the index will be chosen? Whether index will be choosen or not for this query? ...

How do you reindex an array in PHP?

I have the following array, which I would like to reindex so the keys are reversed (ideally starting at 1): Current array (edit: the array actually looks like this): Array ( [2] => Object ( [title] => Section [linked] => 1 ) [1] => Object ( [title] => Sub-Section [linked] => 1 ) [0] =>...

How to return the index of a character in string on iPhone?

I want to split a few strings whose separate marks are different. e.g.separate a string: "A-B^C~D" So I want to get the index of each separate mark. Is there any method like indexOf(' ') on iPhone? ...

Fast page retrieval in MySQL, index usage?

I would like to speed a MySQL query that basically retrieve a page of data following the pattern below select my_field_A, my_field_B where time_id >= UNIX_TIMESTAMP('1901-01-01 00:00:00') AND time_id < UNIX_TIMESTAMP('2009-01-16 00:00:00') The field time_id is an MySQL index, yet, the query behaves as if the entire database was ...

How can I learn SQL Server index tuning?

What is the best practical way of learning index tuning while writing tsql queries? I have VS2008 SQL Express. Could someone please provide me examples, etc? I have already found online articles and they are great in theory, but I still fail to see index tuning in real life action. Are there small easy to create examples out there? ...

What are Covering Indexes and Covered Queries in SQL Server?

Can you explain the concepts of, and relationship between, Covering Indexes and Covered Queries in Microsoft's SQL Server? ...

What's your biggest indexing improvement?

I had a revelation a couple of years ago when optimizing a database table that was running slow. The original query would take around 20 minutes in a table with large data-fields. After finally realizing that noone had bothered to index the table in the first place I built an index for a couple of the keys. Lo and behold, the query ran i...

In JDBC, why do parameter indexes for prepared statements begin at 1 instead of 0?

Everywhere else in Java, anything with an index starts at 0. Is there a reason for the change here or is this just bad design? ...

How can I add search functionality into my PHP website?

Duplicate: How would I implement a simple site search with php and mySQL? I want to insert a search functionality into an existing website. The site is database driven. What is the best way to achieve this? Should i just simply go ahead with the query select * from tables where field like user input? Is there a better way to index the ...

How to properly create an index

I have the following very large table in SQL Server 2005: create table Blah ( FirstName varchar(30), Rank int, Position int, ... ) I will run the following query on it: declare @PassedInFirstName varchar(30) set @PassedInFirstName = 'SomeName' select TOP 1 Position from Blah where FirstName = @PassedInFirstName order by Ran...

Why am I getting this error on my local database and not on my live database?

when I am querying the local database instead of live database I get the following error: Cannot use a CONTAINS or FREETEXT predicate on table or indexed view 'Shop' because it is not full-text indexed. Why is this happening? ...