![]() ![]() They are used to increase the speed of queries on the table by creating columns that are more easily searchable. The first example we showed is an example of a non-clustered table: Non-clustered indexes are sorted references for a specific field, from the main table, that hold pointers back to the original entries of the table. This is where non-clustered indexes become very useful. However, in order to search for the “name” or “city” in the table, we would have to look at every entry because these columns do not have an index. Since the numbers are ordered, the search can navigate the B-tree allowing searches to happen in logarithmic time. ![]() When searching the table by “id”, the ascending order of the column allows for optimal searches to be performed. The created table, “friends”, will have a clustered index automatically created, organized around the Primary Key “id” called “friends_pkey”: Once filled in, that table would look something like this: The clustered index will be automatically created when the primary key is defined:ĬREATE TABLE friends ( id INT PRIMARY KEY, name VARCHAR, city VARCHAR )
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |