Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-28637

Add basic TABLESAMPLE SYSTEM support

    XMLWordPrintable

Details

    Description

      MDEV-19556 adds engine-native record sampling. It also adds code that uses sampling for its primary purpose, that is, to collect histograms.

      However, it is fairly difficult to do testing. Looking at the collected histogram, it is hard to tell whether the sampling code has provided each record the same chance of being in the output, etc.

      This MDEV is about adding the basic TABLESAMPLE syntax support which allows one to examine the sampled rows directly.

      The SQL syntax for TABLESAMPLE feature:

      <table factor> ::=
      <table primary> [ <sample clause> ]
       
      <sample clause> ::=
      TABLESAMPLE <sample method> <left paren> <sample percentage> <right paren>
      [ <repeatable clause> ]
       
       
      <sample method> ::=
      BERNOULLI
      | SYSTEM
       
      <repeatable clause> ::=
      REPEATABLE <left paren> <repeat argument> <right paren>
       
      <sample percentage> ::=
      <numeric value expression>
       
      <repeat argument> ::=
      <numeric value expression>
      

      TABLESAMPLE is a reserved word.

      We allow only this syntax:

      TABLESAMPLE SYSTEM ( number )
      

      We allow it only for SELECTs (not for DML).

      The optimizer will not use any indexes for the table that uses TABLESAMPLE syntax.

      It will also ignore the fact that sampling the table produces fewer rows.

      Attachments

        Issue Links

          Activity

            People

              psergei Sergei Petrunia
              psergei Sergei Petrunia
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.