Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Database Query Search

Name: Anonymous 2011-10-09 1:14

Hello, I would highly appreciate some help with this

Consider this query:
Select * from Employee where salary>10000 sort by salary desc;

How is it actually implemented by the database? If the records are all stored in some sort of a binary search tree, sorted by their index (say the primary key), it's going to be incredibly hard to search and sort the results by salary.

Name: Anonymous 2011-10-09 1:47

It takes linear time to print out the result of th query, so it should alright if radix sort is used to sort the results in linear time.

Name: Anonymous 2011-10-09 3:11

Name: Anonymous 2011-10-09 3:16

>>2
print
Seriously?

And if your table has 200M rows, but your result set only has 5 rows, you're okay with it searching the whole thing?

Name: Anonymous 2011-10-09 3:27

>>4

It takes linear time to print (take the data thingys you are interested in, and copy them over to the other place thingy that stores stuff you are going use and stuff) out the result of th query, so it should alright if radix sort is used to sort the results in linear time.

It would only need to sort the entries that were selected.

>>3

Thank you data friend.

Name: Anonymous 2011-10-09 9:04

>>5
Either you don't have an index, in which case you're doing a butt-slow scan of the whole table, or you have, in which case you're already getting the results in sorted order.

Name: Anonymous 2011-10-09 11:14

>>6

I guess I will have to read up more about indices, but your post seems to imply that you need to set up indices for every column in your table. This seems to be feasible if you map various sets of indices to the same address set of the nodes.

Else it will be a nightmare, as far as disk space and memory is concerned.

Name: Anonymous 2011-10-09 12:58

Yeah it's a serious problem. The indexes usually outweigh the table contents in terms of storage by a factor of like 10:1.

Name: Anonymous 2011-10-09 15:42

>>6

sorted by the primary key is not necessarily sorted by salary.

Don't change these.
Name: Email:
Entire Thread Thread List