Skip to Content
Former Member
Nov 15, 2008 at 07:25 AM

Source code for SQL Optimizer of MaxDB 7.4



I am browsing through the MaxDB source code downloaded at the [SAPDB website||].

I need to understand how MaxDB estimates the selectivity for a given predicate (of the form <column name> <less than|equal to|...> <value>). As far as I know, the optimizer uses the (B+-tree of the) index of the column to estimate selectivity and uses this selectivity estimate in choosing an appropriate plan. I want to see how exactly this is done. I also want to see how the several plans are generated, how one of them wins and how the outputs of the three EXPLAIN vaiants are calculated.

I looked in the folder SAPDB_ORG/sys/src/SAPDB, especially the cpp files in the folder DataAccess, which had some details of how the statistics are calculated by sampling. However, I could not find the source code that answers the above questions. The other folders in SAPDB seemed irrelevant to my question (judging by the name) and the other folders in src have cryptic names that do not give a clue. I did an egrep on the entire src folder looking for "purpose:optim*" ignoring case without finding anything.

Am I looking in the wrong place, or doing it the wrong way?