Doubt in IndexScanDescData

Lists: pgsql-hackers
From: Suresh <suiyengar(at)yahoo(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Doubt in IndexScanDescData
Date: 2008-02-17 15:33:43
Message-ID: 469221.7648.qm@web54505.mail.re2.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

[ "include/access/relscan.h" ]

In IndexScanDescData, whats the purpose of having two Relation variables.

typedef struct IndexScanDescData
{
Relation heapRelation; /* heap relation descriptor, or NULL */
Relation indexRelation; /* index relation descriptor */
....
...
}IndexScanDescData;


---------------------------------
Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.


From: Hans-Juergen Schoenig <postgres(at)cybertec(dot)at>
To: Suresh <suiyengar(at)yahoo(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Doubt in IndexScanDescData
Date: 2008-02-17 15:56:53
Message-ID: ECF95463-D987-4864-8B38-BD1E2C6C52D0@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On Feb 17, 2008, at 4:33 PM, Suresh wrote:

> [ "include/access/relscan.h" ]
>
> In IndexScanDescData, whats the purpose of having two Relation
> variables.
>
> typedef struct IndexScanDescData
> {
> Relation heapRelation; /* heap relation
> descriptor, or NULL */
> Relation indexRelation; /* index relation
> descriptor */
> ....
> ...
> }IndexScanDescData;

The index does not contain the entire tuple. If you index column A
the index will not contain values in column B of the same table.
Thus, if you find a record in the index one of the things which have
to be done is to get the record from disk to check visibility and
other columns.

best regards,

hans-juergen schoenig

--
Cybertec Schönig & Schönig GmbH
PostgreSQL Solutions and Support
Gröhrmühlgasse 26, 2700 Wiener Neustadt
Tel: +43/1/205 10 35 / 340
www.postgresql.at, www.cybertec.at


From: Suresh <suiyengar(at)yahoo(dot)com>
To: Hans-Juergen Schoenig <postgres(at)cybertec(dot)at>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Doubt in IndexScanDescData
Date: 2008-02-17 16:13:56
Message-ID: 343885.48284.qm@web54505.mail.re2.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hans-Juergen Schoenig <postgres(at)cybertec(dot)at> wrote:
On Feb 17, 2008, at 4:33 PM, Suresh wrote:

[ "include/access/relscan.h" ]

In IndexScanDescData, whats the purpose of having two Relation variables.

typedef struct IndexScanDescData
{
Relation heapRelation; /* heap relation descriptor, or NULL */
Relation indexRelation; /* index relation descriptor */
....
...
}IndexScanDescData;

The index does not contain the entire tuple. If you index column A the index will not contain values in column B of the same table.
Thus, if you find a record in the index one of the things which have to be done is to get the record from disk to check visibility and other columns.

Yes thats correct. But I still dont get it. To get record from the disk on match, we need Relation data. But whats the purpose having two seperate Relation variables ?

Does it mean that heaprelation will contain only info about that particular column of the table and index relation will have info about the whole tuple of the relation ?

best regards,

hans-juergen schoenig

--
Cybertec Schönig & Schönig GmbH
PostgreSQL Solutions and Support
Gröhrmühlgasse 26, 2700 Wiener Neustadt
Tel: +43/1/205 10 35 / 340
www.postgresql.at, www.cybertec.at


---------------------------------
Never miss a thing. Make Yahoo your homepage.


From: Hans-Juergen Schoenig <postgres(at)cybertec(dot)at>
To: Suresh <suiyengar(at)yahoo(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Doubt in IndexScanDescData
Date: 2008-02-17 16:22:57
Message-ID: 8352221D-AE86-4D66-B8D0-9CC3574F26D2@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

take a look at that ...

http://www.postgresql.org/docs/8.3/static/indexam.html

this might clear up the problem.
here is an example making clear what happens:

select phone_number from phonebook where name = 'xy';

index is asked to find the right place in the heap to retrieve the data.
this is what happens during an index scan.
i suggest to step tnrough this process with a debugger to see what is
going on.

hans

On Feb 17, 2008, at 5:13 PM, Suresh wrote:

> Hans-Juergen Schoenig <postgres(at)cybertec(dot)at> wrote:
>
> On Feb 17, 2008, at 4:33 PM, Suresh wrote:
>
>> [ "include/access/relscan.h" ]
>>
>> In IndexScanDescData, whats the purpose of having two Relation
>> variables.
>>
>> typedef struct IndexScanDescData
>> {
>> Relation heapRelation; /* heap relation
>> descriptor, or NULL */
>> Relation indexRelation; /* index relation
>> descriptor */
>> ....
>> ...
>> }IndexScanDescData;
>
>
>
> The index does not contain the entire tuple. If you index column A
> the index will not contain values in column B of the same table.
> Thus, if you find a record in the index one of the things which
> have to be done is to get the record from disk to check visibility
> and other columns.
>
> Yes thats correct. But I still dont get it. To get record from the
> disk on match, we need Relation data. But whats the purpose having
> two seperate Relation variables ?
>
> Does it mean that heaprelation will contain only info about that
> particular column of the table and index relation will have info
> about the whole tuple of the relation ?
>
>
> best regards,
> hans-juergen schoenig
>
>
>
> --
> Cybertec Schönig & Schönig GmbH
> PostgreSQL Solutions and Support
> Gröhrmühlgasse 26, 2700 Wiener Neustadt
> Tel: +43/1/205 10 35 / 340
> www.postgresql.at, www.cybertec.at
>
>
>
>
> Never miss a thing. Make Yahoo your homepage.

--
Cybertec Schönig & Schönig GmbH
PostgreSQL Solutions and Support
Gröhrmühlgasse 26, 2700 Wiener Neustadt
Tel: +43/1/205 10 35 / 340
www.postgresql.at, www.cybertec.at


From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Suresh" <suiyengar(at)yahoo(dot)com>
Cc: "Hans-Juergen Schoenig" <postgres(at)cybertec(dot)at>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Doubt in IndexScanDescData
Date: 2008-02-17 17:03:32
Message-ID: 87d4qvtt0b.fsf@oxford.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

One thing you might be missing is that indexes are relations too. They're a
bit different than heap relations (ie "tables") but they share enough
structure that it's worth using the same datatypes to represent both.

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Ask me about EnterpriseDB's RemoteDBA services!


From: Suresh <suiyengar(at)yahoo(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Doubt in heap_release_fetch
Date: 2008-03-07 05:46:14
Message-ID: 165201.27422.qm@web54503.mail.re2.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello,

What do the following lines mean :

/* Tuple failed time qual, but maybe caller wants to see it anyway. */
if (keep_buf)
*userbuf = buffer;
else
{
ReleaseBuffer(buffer);
*userbuf = InvalidBuffer;
}

What is the time qualification check ?

Thanks,
Suresh


---------------------------------
Never miss a thing. Make Yahoo your homepage.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Suresh <suiyengar(at)yahoo(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Doubt in heap_release_fetch
Date: 2008-03-07 05:57:55
Message-ID: 6992.1204869475@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Suresh <suiyengar(at)yahoo(dot)com> writes:
> What is the time qualification check ?

HeapTupleSatisfiesVisibility(). See
src/include/utils/tqual.h
src/backend/utils/time/tqual.c
and if none of this is making any sense maybe you need to start here:
http://developer.postgresql.org/pgdocs/postgres/mvcc.html

regards, tom lane


From: Suresh <suiyengar(at)yahoo(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Doubt in index scan code
Date: 2008-03-08 16:06:18
Message-ID: 597790.92025.qm@web54504.mail.re2.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello all,

I have a custom code written inside postgres in an application we use.
The snippet is as below :
Here inner plan is an index scan.

scandesc = ((IndexScanState *)innerPlan)->iss_ScanDesc;

flag=index_getmulti(scandesc, &tidelm->tid, 1, &ret_tids);

Now consider a query like

explain select * from dept,manager where did=id ;
QUERY PLAN
---------------------------------------------------------------------------
Nested Loop (cost=0.00..269.09 rows=45 width=72)
-> seq scan on manager (cost=0.00..6.50 rows=45 width=36)
-> Index Scan using id1 on dept (cost=0.00..5.82 rows=1 width=36)
Index Cond: ("outer".did = dept.id)

Say seq scan retrieves did in the order 30,10, 20.. My doubt is in what order
will index_getmulti return tids. How does the scandesc work ?

Will it return the tids as firstly macthing inners for dept=30, then dept=10 ?

Please help me with this.

Thanks and regards,
Suresh


---------------------------------
Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.


From: Dave Cramer <pg(at)fastcrypt(dot)com>
To: Suresh <suiyengar(at)yahoo(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Doubt in index scan code
Date: 2008-03-08 22:12:25
Message-ID: E7832549-40CE-48BD-B3B0-4BC463F9F97F@fastcrypt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On 8-Mar-08, at 11:06 AM, Suresh wrote:

> Hello all,
>
> I have a custom code written inside postgres in an application we use.
> The snippet is as below :
> Here inner plan is an index scan.
>
> scandesc = ((IndexScanState *)innerPlan)->iss_ScanDesc;
>
> flag=index_getmulti(scandesc, &tidelm->tid, 1, &ret_tids);
>
> Now consider a query like
>
> explain select * from dept,manager where did=id ;
> QUERY PLAN
> ---------------------------------------------------------------------------
> Nested Loop (cost=0.00..269.09 rows=45 width=72)
> -> seq scan on manager (cost=0.00..6.50 rows=45 width=36)
> -> Index Scan using id1 on dept (cost=0.00..5.82 rows=1 width=36)
> Index Cond: ("outer".did = dept.id)
>
> Say seq scan retrieves did in the order 30,10, 20.. My doubt is in
> what order
> will index_getmulti return tids. How does the scandesc work ?
>
> Will it return the tids as firstly macthing inners for dept=30, then
> dept=10 ?
>
since you have no order by clause in the query rows will be returned
in the order they are found on the disc.

Dave
> Please help me with this.
>
> Thanks and regards,
> Suresh
>
>
>
>
>
>
>
>
>
>
>
> Be a better friend, newshound, and know-it-all with Yahoo! Mobile.
> Try it now.


From: Suresh <suiyengar(at)yahoo(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: segfault in locking code
Date: 2008-03-28 14:54:03
Message-ID: 659831.88137.qm@web54506.mail.re2.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello,

I have a custom code in postgres which runs properly in some occasions and segfaults some times. The trace is as below :

Program received signal SIGSEGV, Segmentation fault.
0x081ae8c4 in LWLockRelease (lockid=664)
at ../../../../src/include/storage/s_lock.h:128
128 __asm__ __volatile__(

(gdb) where
#0 0x081ae8c4 in LWLockRelease (lockid=664)
at ../../../../src/include/storage/s_lock.h:128
#1 0x0808f820 in heap_fetch_tuple (relation=0xb5d986d8, snapshot=0xa298aa0,
buffer=305, tid=0xa23f600, tuple=0xa29db0c, pgstat_info=0xa29db30,
tupStat=0xbfac9374) at heapam.c:3404
#2 0x08144df2 in ExecNestLoop (node=0xa298f30) at nodeNestloop.c:452
#3 0x08136840 in ExecProcNode (node=0xa298f30) at execProcnode.c:352
#4 0x08135ba1 in ExecutorRun (queryDesc=0xa298ac8,
direction=ForwardScanDirection, count=0) at execMain.c:1162
#5 0x081b7e60 in PortalRunSelect (portal=0xa296a98,
forward=<value optimized out>, count=0, dest=0x82d3308) at pquery.c:794
#6 0x081b8a88 in PortalRun (portal=0xa296a98, count=2147483647,
dest=0x82d3308, altdest=0x82d3308, completionTag=0xbfac9608 "")
at pquery.c:646
#7 0x081b48fc in exec_simple_query (
query_string=0xa275b58 "select l_orderkey as a from tpcd.orders, tpcd.lineitem where o_orderkey=l_orderkey ;\n") at postgres.c:1003
#8 0x081b6371 in PostgresMain (argc=1, argv=0xa2379f0,
username=0xa238398 "suresh") at postgres.c:3221
#9 0x081532e3 in main (argc=2, argv=Cannot access memory at address 0xfffffffd
) at main.c:411

It segfaults in the locking _asm_ code. What could be the reason for this variable behavior ?

Thanks and regards,
Suresh


---------------------------------
Never miss a thing. Make Yahoo your homepage.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Suresh <suiyengar(at)yahoo(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: segfault in locking code
Date: 2008-03-28 15:10:03
Message-ID: 9532.1206717003@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Suresh <suiyengar(at)yahoo(dot)com> writes:
> I have a custom code in postgres which runs properly in some occasions and segfaults some times. The trace is as below :

The traceback you show appears to lead through code that doesn't exist
in any public version of Postgres. So I think it's your own bug to
solve.

regards, tom lane


From: Suresh <suiyengar(at)yahoo(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Getting statistics
Date: 2008-04-29 13:05:32
Message-ID: 471902.34779.qm@web54505.mail.re2.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello,

I want to collect various statistics like time taken, number of context switches, page faults etc.. for a query being run. postgres.c contains lots of getrusage related things.

Is there any way to calculate all the things without writing any custom code ?

Thanks and regards,
Suresh


---------------------------------
Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.


From: Suresh <suiyengar(at)yahoo(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Stack depth exceeded error
Date: 2008-05-12 13:05:08
Message-ID: 808226.554.qm@web54502.mail.re2.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello,

I have custom postgres code. I get the error below for the query

"select l_orderkey as a from tpcd.orders, tpcd.lineitem where o_orderkey=l_orderkey and l_partkey<100 and l_linestatus='F';"

ERROR: stack depth limit exceeded
HINT: Increase the configuration parameter "max_stack_depth".

However, the same code runs fine with one condition in where clause, but fails with the error above in case of multiple conditions.

Whats the cause of this error ? I tried increasing the stack limit; but it doesnt help.

--
Suresh Iyengar


---------------------------------
Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.


From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: "Suresh" <suiyengar(at)yahoo(dot)com>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Stack depth exceeded error
Date: 2008-05-12 13:49:55
Message-ID: 873aonzl6k.fsf@oxford.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

"Suresh" <suiyengar(at)yahoo(dot)com> writes:

> Hello,
>
> I have custom postgres code.

What kind of code is this? The error below is typical if you create new
threads in the server.

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Ask me about EnterpriseDB's 24x7 Postgres support!


From: Suresh <suiyengar(at)yahoo(dot)com>
To: Gregory Stark <stark(at)enterprisedb(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Stack depth exceeded error
Date: 2008-05-12 13:57:11
Message-ID: 40297.47953.qm@web54504.mail.re2.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

The code uses Asynchronous I/O for fetching certain tids. The code works fine if I use only one condition in where condition, but fails if I use multiple condition.

--
Suresh Iyengar

Gregory Stark <stark(at)enterprisedb(dot)com> wrote: "Suresh" writes:

> Hello,
>
> I have custom postgres code.

What kind of code is this? The error below is typical if you create new
threads in the server.

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Ask me about EnterpriseDB's 24x7 Postgres support!


---------------------------------
Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.


From: Suresh <suiyengar(at)yahoo(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Doubt in index subplan query
Date: 2008-06-20 06:11:47
Message-ID: 387960.33875.qm@web54506.mail.re2.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello,

I have a query plan for a certain query

 Nested Loop  (cost=100000000.00..38761761090.50 rows=3000608 width=8)
   ->  Seq Scan on lineitem  (cost=100000000.00..100213649.15 rows=6001215 width=8)
   ->  Index Scan using oindex2 on myorders  (cost=0.00..6442.27 rows=1 width=4)
         Index Cond: ("outer".l_orderkey = myorders.o_orderkey)
         Filter: (subplan)
         SubPlan
           ->  Index Scan using cnation on customer  (cost=0.00..12859.39 rows=5251 width=0)
                 Index Cond: (c_nationkey = 10)

How is the subplan handled by postgres at index level ? Is any sort of hashing done ?

Thanks and regards,
Suresh


From: Decibel! <decibel(at)decibel(dot)org>
To: suiyengar(at)yahoo(dot)com
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Doubt in index subplan query
Date: 2008-06-20 16:14:47
Message-ID: 790D81E2-3278-415E-89C7-900B9896A708@decibel.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Jun 20, 2008, at 1:11 AM, Suresh wrote:
> I have a query plan for a certain query
>
> Nested Loop (cost=100000000.00..38761761090.50 rows=3000608 width=8)
> -> Seq Scan on lineitem (cost=100000000.00..100213649.15
> rows=6001215 width=8)
> -> Index Scan using oindex2 on myorders (cost=0.00..6442.27
> rows=1 width=4)
> Index Cond: ("outer".l_orderkey = myorders.o_orderkey)
> Filter: (subplan)
> SubPlan
> -> Index Scan using cnation on customer
> (cost=0.00..12859.39 rows=5251 width=0)
> Index Cond: (c_nationkey = 10)
>
> How is the subplan handled by postgres at index level ? Is any sort
> of hashing done ?

This is better asked on pgsql-general... but the subplan does exactly
what it says; an index scan. It will be executed for every row of the
calling query.
--
Decibel!, aka Jim C. Nasby, Database Architect decibel(at)decibel(dot)org
Give your computer some brain candy! www.distributed.net Team #1828


From: Suresh <suiyengar(at)yahoo(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Checking stack depth
Date: 2008-10-29 03:16:33
Message-ID: 191906.31038.qm@web54501.mail.re2.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello,

Why is check_stack_depth function enforced in context of evaluating expressions in PostgreSQL ? What sort of recursion we are trying to safeguard ?

thanks,
Suresh


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: suresh(at)cse(dot)iitb(dot)ac(dot)in
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Checking stack depth
Date: 2008-10-29 03:20:32
Message-ID: 3869.1225250432@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Suresh <suiyengar(at)yahoo(dot)com> writes:
> Why is check_stack_depth function enforced in context of evaluating expressions in PostgreSQL ? What sort of recursion we are trying to safeguard ?

create function foo(int) returns int as $$
select foo($1) $$ language sql;

select foo(1);

regards, tom lane