开发者

Which table column to Index?

I have a table which has columns A, B, C, D.

I have an application which searches a word in ALL the columns of the table.

If I want to index the table so that search happens faster, which column should I index?

How will th开发者_运维问答e index command look?

EDIT: Actually, I have 27 columns of Languages (e.g. English, German, etc). I have an application which searches a word in all the languages and returns a result.

How to do index this table to ensure faster search result?


You need a full-text index on all columns.

Unfortunately SQLite doesn't support full-text indexes by default. You have to compile it with optional full-text index support enabled.

As unhelpful as it may be to just point you at the docs for SQLite's Full-Text indexing, here they are: http://www.sqlite.org/fts3.html


You should either use a full-text index, if your database supports this, or put a "normal" index on each column with a "create index" statement. The syntax might differ from database to database, so I can't give you a code sample here.


Do you have only those columns? how large is your database? how often your data is refreshed. What kind of queries are you performing (like queries mostly). What is your database engine?

your answers to these may lead to, no index at all, indexes on each of those 4 columns, a full-text index.


Please notice these Links about:

SQL Performance Tuning using Indexes and The SQLite Query Planner

and specially the section Building The Best Index in the 1st Link

You may want to consider the option of 4 Indexes, one per column, so up to the language you are searching in, you can sort using the Index you need.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜