0% found this document useful (0 votes)
59 views1 page

Foreign Key Optimization: Create Unique Fulltext Spatial Index ON

Splitting less frequently used data into separate tables with a primary key and relating them to the main table through a duplicated ID column can improve performance. This allows each small table to have a primary key for fast lookups and queries to retrieve just the needed columns through joins, which may reduce I/O and memory usage since relevant columns are packed together.

Uploaded by

speedmail71
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views1 page

Foreign Key Optimization: Create Unique Fulltext Spatial Index ON

Splitting less frequently used data into separate tables with a primary key and relating them to the main table through a duplicated ID column can improve performance. This allows each small table to have a primary key for fast lookups and queries to retrieve just the needed columns through joins, which may reduce I/O and memory usage since relevant columns are packed together.

Uploaded by

speedmail71
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Foreign Key Optimization

If a table has many columns, and you query many different combinations of columns, it
might be efficient to split the less-frequently used data into separate tables with a few
columns each, and relate them back to the main table by duplicating the numeric ID column
from the main table. That way, each small table can have a primary key for fast lookups of
its data, and you can query just the set of columns that you need using a join operation.
Depending on how the data is distributed, the queries might perform less I/O and take up
less cache memory because the relevant columns are packed together on disk. (To
maximize performance, queries try to read as few data blocks as possible from disk; tables
with only a few columns can fit more rows in each data block.)

CREATE INDEX Syntax


CREATE [UNIQUE | FULLTEXT | SPATIAL] INDEX index_name
[index_type]
ON tbl_name (key_part,...)
[index_option]
[algorithm_option | lock_option] ...

key_part: {col_name [(length)] | (expr)} [ASC | DESC]

index_option:
KEY_BLOCK_SIZE [=] value
| index_type
| WITH PARSER parser_name
| COMMENT 'string'
| {VISIBLE | INVISIBLE}

index_type:
USING {BTREE | HASH}

algorithm_option:
ALGORITHM [=] {DEFAULT | INPLACE | COPY}

lock_option:
LOCK [=] {DEFAULT | NONE | SHARED | EXCLUSIVE}

Suppose that a table has the following specification:

CREATE TABLE test (


id INT NOT NULL,
last_name CHAR(30) NOT NULL,
first_name CHAR(30) NOT NULL,
PRIMARY KEY (id),
INDEX name (last_name,first_name)
);

You might also like