111 double spc_random_page_cost;
120 !((
Const *) limitnode)->constisnull)
123 if (millis < 0 || isnan(millis))
137 &spc_random_page_cost,
146 if (spc_random_page_cost > 0)
147 npages = millis / spc_random_page_cost;
157 double density = baserel->
tuples / (double) baserel->
pages;
159 ntuples = npages * density;
196 if (millis < 0 || isnan(millis))
198 (
errcode(ERRCODE_INVALID_TABLESAMPLE_ARGUMENT),
199 errmsg(
"sample collection time must not be negative")));
201 sampler->
seed = seed;
224 if (sampler->
step == 0)
272 sampler->
lb = ((uint64) sampler->
lb + sampler->
step) % sampler->
nblocks;
273 }
while (sampler->
lb >= nblocks);
302 if (tupoffset > maxoffset)
305 sampler->
lt = tupoffset;
350 }
while (r == 0 ||
gcd(r, n) > 1);
#define InvalidBlockNumber
Node * estimate_expression_value(PlannerInfo *root, Node *node)
double clamp_row_est(double nrows)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
#define PG_RETURN_POINTER(x)
#define INSTR_TIME_SET_CURRENT(t)
#define INSTR_TIME_SUBTRACT(x, y)
#define INSTR_TIME_GET_MILLISEC(t)
if(TABLE==NULL||TABLE_index==NULL)
void * palloc0(Size size)
#define CHECK_FOR_INTERRUPTS()
#define IsA(nodeptr, _type_)
#define InvalidOffsetNumber
#define FirstOffsetNumber
#define list_make1_oid(x1)
static float8 DatumGetFloat8(Datum X)
double sampler_random_fract(pg_prng_state *randstate)
void sampler_random_init_state(uint32 seed, pg_prng_state *randstate)
void get_tablespace_page_costs(Oid spcid, double *spc_random_page_cost, double *spc_seq_page_cost)
NextSampleTuple_function NextSampleTuple
bool repeatable_across_scans
EndSampleScan_function EndSampleScan
SampleScanGetSampleSize_function SampleScanGetSampleSize
BeginSampleScan_function BeginSampleScan
NextSampleBlock_function NextSampleBlock
InitSampleScan_function InitSampleScan
bool repeatable_across_queries
Datum tsm_system_time_handler(PG_FUNCTION_ARGS)
static void system_time_samplescangetsamplesize(PlannerInfo *root, RelOptInfo *baserel, List *paramexprs, BlockNumber *pages, double *tuples)
static uint32 random_relative_prime(uint32 n, pg_prng_state *randstate)
PG_FUNCTION_INFO_V1(tsm_system_time_handler)
static void system_time_beginsamplescan(SampleScanState *node, Datum *params, int nparams, uint32 seed)
static uint32 gcd(uint32 a, uint32 b)
static void system_time_initsamplescan(SampleScanState *node, int eflags)
static OffsetNumber system_time_nextsampletuple(SampleScanState *node, BlockNumber blockno, OffsetNumber maxoffset)
static BlockNumber system_time_nextsampleblock(SampleScanState *node, BlockNumber nblocks)