I am wondering if a table or particularly a heap file with a clustered index created on one of the attributes is sorted on that attribute.Is there a difference between a sorted heap file and a heap file with clustered index ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Sorted heap file is a heap (array-like structure) with the elements ordered. This is what
MyISAMdoes withALTER TABLE … ORDER BY …orPostgreSQLdoes withCLUSTER. Inserting a new record into such a table breaks the order.Clustered index is a
B-Tree. Inserting a new record keeps the order.The records in a clustered table are not necessarily physically ordered (in a sense that the record with a higher value of the clustering key has a higher offset in a file or tablespace).
Rather, the records are logically ordered: you can traverse from one record to another following
B-Treelinks (or direct links between pages in case of aB+Tree), but this still implies random disk seeks because the pages linked logically do not necessarily reside near each other on the disk.Some databases,
Oraclefor instance, allow reading the indexes in physical order (using an operation known asINDEX FAST FULL SCAN) which does not maintain the logical order but is faster because of the benefits or sequential access to the pages.There is no such thing as a “heap file with a clustered index”: a table organization is either heap or clustered.