Re: [HACKERS] Getting table name/tuple from OID

2005-11-11 Thread huaxin zhang
Hi all,

I am interested in the answer as well -- how to get a table name (or
an operator name)
from an OID.the parser must know how to do this, but the segment
of code is hard
to locate.

thanks a lot,
Huaxin


On 11/7/05, Paresh Bafna [EMAIL PROTECTED] wrote:
 Actually I want to do this from inside the postgres code i.e. I want to
 get table name and tuple values from OID of corresponding table OID and
 tuple OID.
 Is there any built in function in postgres code to do this?

 Paresh

 Christopher Kings-Lynne wrote:

  Try
 
  SELECT 12341234::regclass;
 
  Where 12341234 is the OID of a table.
 
  Otherwise try:
 
  SELECT tableoid, * FROM table;
 
  To get the tableoid on each row.
 
  Chris
 
  Paresh Bafna wrote:
 
  Is there any way to retrieve table name and/or tuple values from OID of
  table/tuple?
 
  ---(end of broadcast)---
  TIP 5: don't forget to increase your free space map settings
 
 
  ---(end of broadcast)---
  TIP 5: don't forget to increase your free space map settings



 ---(end of broadcast)---
 TIP 5: don't forget to increase your free space map settings


---(end of broadcast)---
TIP 6: explain analyze is your friend


[HACKERS] counting disk access from index seek operation -- how to?

2005-09-11 Thread huaxin zhang
I need a way to tell how many pages loaded from disk for a particular
index seek operation.

What I did is to set a global flag to true before calling the
following statement
(inside index_getnext() in /backend/access/indexam.c)

  found = DatumGetBool(FunctionCall2(scan-fn_getnext,
   PointerGetDatum(scan),
  
Int32GetDatum(direction)));


then for each access to disk, I increment a counter until the above call is
finished and set back the global flag.

The number of page IOs is not even matching from what I got from 
select * from pg_stat_all_indexes  ---  (is there anything I need to
set in postgresql.conf?)

also, the number of paged IOs for a given index seek is always less
than the total
page loads. Is it because of the statement (following the above in 
/backend/access/indexam.c)?

if (heap_release_fetch(scan-heapRelation, scan-xs_snapshot,  

  heapTuple, scan-xs_cbuf, true,
   scan-xs_pgstat_info))

If I am running in a single user mode, is there a way to avoid using
extra page IO in
the above statement? It seems to me the extra page IO is caused by
comparing snapshots...

thanks

---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
   choose an index scan if your joining column's datatypes do not
   match


[HACKERS] purge hash table, how to?

2005-09-06 Thread huaxin zhang
i am using postgresql 8.0.3 as a single user by running postgres

I want to purge all contents in the bufferpool, and I did this by
calling InitBufTable(256) (buf_table.c)  after each query. However,
this seems not working for each followup query I still get less disk read
(tracked by smgrread()  in smgr.c) and increased bufferhitcount.

Could anyone tell me which module shall i modify instead?

---(end of broadcast)---
TIP 2: Don't 'kill -9' the postmaster


[HACKERS] count(*) optimization

2005-09-06 Thread huaxin zhang
not sure where to put this. 

I run two queries: 

1. select count(*) from table where indexed_column10;
2. select * from table where indexed_column10;

the indexed column is not clustered at all. I saw from the trace that
both query runs
through index scans on that index and takes the same amount of buffer
hits and disk read. However, shouldn't the optimizer notice that the
first query only needs to look at the indexes
and possibly reduce the amount of buffer/disk visits?

thanks

---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
   choose an index scan if your joining column's datatypes do not
   match


Re: [HACKERS] 8.1 and syntax checking at create time

2005-08-31 Thread huaxin zhang
I am new to this hacker's job. What I was looking for was to record
the actual disk IO performed for arbituary query plan. I searched
in backend/executor but not sure if that was the right place to 
add a tracer. would the /backend/storage be the place that controls
the actual I/O? btw, is there a way to find the definitions of all variables
or functions defined? I tried cscope but it is not good for such a large 
framework.

thanks a lot