When a SQL is translated to C by parser such as YACC or BISON, does that piece of translated C code contains the the sorting algorithm mathematics? I do not understand how the sorting is implemented in a DBMS (such as MySQL or Microsoft SQL Server) - is the algorithm part of the grammar parser? Or, does the algorithm applies to a resulted group of data only after it get fetched from an SQL query, but not directly apply to the computer memory? Or is the sorting algorithm an ISO standard and that all DBMS are required to use the same algorithm?
I did my researched and googling but find no clear answer. Without unneedingly reading a book on database internal, could someone explain the concept clearly?
The SQL standard does not include any specifications on how sorting should be done. When you issue a query with order by
, it's the database's responsibility to return a result in the specified order, but each database is free to implement this however it sees fit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With