Re: Scans are offloaded to SeqScan instead of CustomScan when there are multiple relations in the same query

2023-04-17 Thread Amin
wrote: > Amin writes: > > To simplify: Can CustomScan scan multiple relations in the same query or > it > > will always be assigned to one or zero relations? > > There's barely any code in the core planner that is specific to custom > scans. Almost certainly this misbe

Re: Scans are offloaded to SeqScan instead of CustomScan when there are multiple relations in the same query

2023-04-17 Thread Amin
To simplify: Can CustomScan scan multiple relations in the same query or it will always be assigned to one or zero relations? On Fri, Apr 14, 2023 at 4:33 PM Amin wrote: > Hi there, > > In my implementation of CustomScan, when I have a query that scans > multiple tables (select c f

Scans are offloaded to SeqScan instead of CustomScan when there are multiple relations in the same query

2023-04-14 Thread Amin
Hi there, In my implementation of CustomScan, when I have a query that scans multiple tables (select c from t1,t2,t3), the planner always picks one table to be scanned by CustomScan and offloads the rest to SeqScan. I tried assigning a cost of 0 to the CustomScan path, but still not working.

NumericShort vs NumericLong format

2023-03-06 Thread Amin
Hi, - How can I determine which format will be used for a numeric type? - What the precision and scale values should be for pgsql to use the long format? Is there a threshold?

Share variable between psql backends in CustomScan

2023-02-17 Thread Amin
Hi, I am looking for a way to define a global variable in CustomScan plugin that is shared between different psql backends. Is it possible without using shared memory? Does postgresql implement any function that facilitates this? Thank you, Amin

Re: Scan buffercache for a table

2023-01-30 Thread Amin
. However, I want to scan a specific table cache pages. On Mon, Jan 30, 2023 at 6:43 PM Justin Pryzby wrote: > On Mon, Jan 30, 2023 at 06:01:08PM -0800, Amin wrote: > > Hi, > > > > I am looking for function calls to scan the buffer cache for a table and > > find the cache

Scan buffercache for a table

2023-01-30 Thread Amin
Hi, I am looking for function calls to scan the buffer cache for a table and find the cached pages. I want to find out which pages are cached and which of them are dirty. Having the relation id, how can I do that? I have gone through bufmgr.c and relcache.c, but could not find a way to get

Re: How to find the number of cached pages for a relation?

2023-01-27 Thread Amin
2023 at 6:27 PM Andres Freund wrote: > Hi, > > On 2023-01-13 17:28:31 -0800, Amin wrote: > > Before scanning a relation, in the planner stage, I want to make a call > to > > retrieve information about how many pages will be a hit for a specific > > relation. The

Getting relations accessed by a query using the raw query string

2023-01-24 Thread Amin
Hi, Having a query string, I am trying to use the postgres parser to find which relations the query accesses. This is what I currently have: const char *query_string="select * from dummytable;"; List *parsetree_list=pg_parse_query(query_string); ListCell *parsetree_item;

How to find the number of cached pages for a relation?

2023-01-13 Thread Amin
Hi, Before scanning a relation, in the planner stage, I want to make a call to retrieve information about how many pages will be a hit for a specific relation. The module pg_buffercache seems to be doing a similar thing. Also, pg_statio_all_tables seems to be having that information, but it is

Re: Get access to the whole query in CustomScan path callback

2023-01-13 Thread Amin
I cannot find any information related to other relations in the query other than the one which is being scanned in the root pointer. Is there any function call which can be used to get access to it? On Wed, Dec 21, 2022 at 9:46 AM Tom Lane wrote: > Amin writes: > > The goal is to ha

Get relid for a relation

2023-01-13 Thread Amin
Hi, In CustomScan cost estimator, where PlannerInfo and RelOptInfo are passed, I want to get access to the relation stats (for example pg_stat_all_tables) by calling pg_stat_fetch_stat_tabentry(). However, I don't have access to relid to pass to this function. For a sample relation, when I

Get access to the whole query in CustomScan path callback

2022-12-21 Thread Amin
Hi, The goal is to have access to all the tables that are being scanned or will be scanned as a part of the query. Basically, the callback looks like this: typedef void (*set_rel_pathlist_hook_type) (PlannerInfo *root, RelOptInfo *rel,

Creating HeapTuple from char and date values

2022-12-07 Thread Amin
Hi All, I am trying to create HeapTuple data structure. First, I create a tuple descriptor: TupleDesc *td=CreateTemplateTupleDesc(colCount); Then, for each variable, I do: TupleDescInitEntry(*td,v->varattno,NULL,v->vartype,v->vartypmod,0); Then, I assign values: if int32:

Traversing targetlist to find accessed columns

2022-12-03 Thread Amin
Hi, Having a query, I am trying to find out all the columns that need to be accessed (their varattno and vartype). I have access to a targetlist representing a tree like this. So, I am looking for a function that recursively traverses the tree and gives me the VARs. So, for SELECT a,b,b+c from