Re: [PATCHES] Fix pgstatindex using for large indexes
Hi. Tom Lane wrote: I think that max_avail and free_space should be uint64. Most places where we've dealt with this before, we use double, which is guaranteed to be available whereas uint64 is not ... Oh I see. I fix the patch. # I changed max_avail and free_space to double. Best regards. -- NTT OSS Center Tatsuhito Kasahara kasahara.tatsuhito _at_ oss.ntt.co.jp *** postgresql-8.3.0.org/contrib/pgstattuple/pgstatindex.c 2007-11-16 06:14:31.0 +0900 --- postgresql-8.3.0/contrib/pgstattuple/pgstatindex.c 2008-02-24 19:35:09.0 +0900 *** *** 68,75 uint32 empty_pages; uint32 deleted_pages; ! uint32 max_avail; ! uint32 free_space; uint32 fragments; } BTIndexStat; --- 68,75 uint32 empty_pages; uint32 deleted_pages; ! double max_avail; ! double free_space; uint32 fragments; } BTIndexStat; *** *** 87,94 Relationrel; RangeVar *relrv; Datum result; ! uint32 nblocks; ! uint32 blkno; BTIndexStat indexStat; if (!superuser()) --- 87,94 Relationrel; RangeVar *relrv; Datum result; ! BlockNumber nblocks; ! BlockNumber blkno; BTIndexStat indexStat; if (!superuser()) *** *** 207,231 values[j] = palloc(32); snprintf(values[j++], 32, %d, indexStat.level); values[j] = palloc(32); ! snprintf(values[j++], 32, %d, (indexStat.root_pages + ! indexStat.leaf_pages + ! indexStat.internal_pages + ! indexStat.deleted_pages + ! indexStat.empty_pages) * BLCKSZ); values[j] = palloc(32); snprintf(values[j++], 32, %d, indexStat.root_blkno); values[j] = palloc(32); ! snprintf(values[j++], 32, %d, indexStat.internal_pages); values[j] = palloc(32); ! snprintf(values[j++], 32, %d, indexStat.leaf_pages); values[j] = palloc(32); ! snprintf(values[j++], 32, %d, indexStat.empty_pages); values[j] = palloc(32); ! snprintf(values[j++], 32, %d, indexStat.deleted_pages); values[j] = palloc(32); ! snprintf(values[j++], 32, %.2f, 100.0 - (float) indexStat.free_space / (float) indexStat.max_avail * 100.0); values[j] = palloc(32); ! snprintf(values[j++], 32, %.2f, (float) indexStat.fragments / (float) indexStat.leaf_pages * 100.0); tuple = BuildTupleFromCStrings(TupleDescGetAttInMetadata(tupleDesc), values); --- 207,231 values[j] = palloc(32); snprintf(values[j++], 32, %d, indexStat.level); values[j] = palloc(32); ! snprintf(values[j++], 32, %.0f, ( (double) indexStat.root_pages + ! (double) indexStat.leaf_pages + ! (double) indexStat.internal_pages + ! (double) indexStat.deleted_pages + ! (double) indexStat.empty_pages) * BLCKSZ); values[j] = palloc(32); snprintf(values[j++], 32, %d, indexStat.root_blkno); values[j] = palloc(32); ! snprintf(values[j++], 32, %u, indexStat.internal_pages); values[j] = palloc(32); ! snprintf(values[j++], 32, %u, indexStat.leaf_pages); values[j] = palloc(32); ! snprintf(values[j++], 32, %u, indexStat.empty_pages); values[j] = palloc(32); ! snprintf(values[j++], 32, %u, indexStat.deleted_pages); values[j] = palloc(32); ! snprintf(values[j++], 32, %.2f, 100.0 - indexStat.free_space / indexStat.max_avail * 100.0); values[j] = palloc(32); ! snprintf(values[j++], 32, %.2f, (double) indexStat.fragments / (double) indexStat.leaf_pages * 100.0); tuple = BuildTupleFromCStrings(TupleDescGetAttInMetadata(tupleDesc), values);
Re: [PATCHES] Fix pgstatindex using for large indexes
Tatsuhito Kasahara wrote: I fix the patch. Oops, I forgot to attach the patch for pgstattuple.sql. I send it again. Best regards. -- NTT OSS Center Tatsuhito Kasahara kasahara.tatsuhito _at_ oss.ntt.co.jp diff -crN postgresql-8.3.0.org/contrib/pgstattuple/pgstatindex.c postgresql-8.3.0/contrib/pgstattuple/pgstatindex.c *** postgresql-8.3.0.org/contrib/pgstattuple/pgstatindex.c 2007-11-16 06:14:31.0 +0900 --- postgresql-8.3.0/contrib/pgstattuple/pgstatindex.c 2008-02-24 19:35:09.0 +0900 *** *** 68,75 uint32 empty_pages; uint32 deleted_pages; ! uint32 max_avail; ! uint32 free_space; uint32 fragments; } BTIndexStat; --- 68,75 uint32 empty_pages; uint32 deleted_pages; ! double max_avail; ! double free_space; uint32 fragments; } BTIndexStat; *** *** 87,94 Relationrel; RangeVar *relrv; Datum result; ! uint32 nblocks; ! uint32 blkno; BTIndexStat indexStat; if (!superuser()) --- 87,94 Relationrel; RangeVar *relrv; Datum result; ! BlockNumber nblocks; ! BlockNumber blkno; BTIndexStat indexStat; if (!superuser()) *** *** 207,231 values[j] = palloc(32); snprintf(values[j++], 32, %d, indexStat.level); values[j] = palloc(32); ! snprintf(values[j++], 32, %d, (indexStat.root_pages + ! indexStat.leaf_pages + ! indexStat.internal_pages + ! indexStat.deleted_pages + ! indexStat.empty_pages) * BLCKSZ); values[j] = palloc(32); snprintf(values[j++], 32, %d, indexStat.root_blkno); values[j] = palloc(32); ! snprintf(values[j++], 32, %d, indexStat.internal_pages); values[j] = palloc(32); ! snprintf(values[j++], 32, %d, indexStat.leaf_pages); values[j] = palloc(32); ! snprintf(values[j++], 32, %d, indexStat.empty_pages); values[j] = palloc(32); ! snprintf(values[j++], 32, %d, indexStat.deleted_pages); values[j] = palloc(32); ! snprintf(values[j++], 32, %.2f, 100.0 - (float) indexStat.free_space / (float) indexStat.max_avail * 100.0); values[j] = palloc(32); ! snprintf(values[j++], 32, %.2f, (float) indexStat.fragments / (float) indexStat.leaf_pages * 100.0); tuple = BuildTupleFromCStrings(TupleDescGetAttInMetadata(tupleDesc), values); --- 207,231 values[j] = palloc(32); snprintf(values[j++], 32, %d, indexStat.level); values[j] = palloc(32); ! snprintf(values[j++], 32, %.0f, ( (double) indexStat.root_pages + ! (double) indexStat.leaf_pages + ! (double) indexStat.internal_pages + ! (double) indexStat.deleted_pages + ! (double) indexStat.empty_pages) * BLCKSZ); values[j] = palloc(32); snprintf(values[j++], 32, %d, indexStat.root_blkno); values[j] = palloc(32); ! snprintf(values[j++], 32, %u, indexStat.internal_pages); values[j] = palloc(32); ! snprintf(values[j++], 32, %u, indexStat.leaf_pages); values[j] = palloc(32); ! snprintf(values[j++], 32, %u, indexStat.empty_pages); values[j] = palloc(32); ! snprintf(values[j++], 32, %u, indexStat.deleted_pages); values[j] = palloc(32); ! snprintf(values[j++], 32, %.2f, 100.0 - indexStat.free_space / indexStat.max_avail * 100.0); values[j] = palloc(32); ! snprintf(values[j++], 32, %.2f, (double) indexStat.fragments / (double) indexStat.leaf_pages * 100.0); tuple = BuildTupleFromCStrings(TupleDescGetAttInMetadata(tupleDesc), values); diff -crN
[PATCHES] Reference by output in : \d table_name
Hi, Refering to this request http://momjian.us/mhonarc/patches_hold/msg00022.htmlI have created a patch. The output doesn't exaclty match with what is stated here http://momjian.us/mhonarc/patches_hold/msg00023.html. However, it does tell the required details in a similar format. Comments? Thanks, Kenneth osdb_pgarch=# \d htest Table public.htestColumn| Type | Modifiers--+---+--- new_id | integer | not null test_name| character(20) | test_cust_id | integer |Indexes:htest_pkey PRIMARY KEY, btree (new_id)Foreign-key constraints: htest_test_cust_id_fkey FOREIGN KEY (test_cust_id) REFERENCES customers(customer_id)Refrenced by : htest_child_ctest_cust_id_fkey IN public.htest_child(ctest_cust_id) REFERENCES htest(new_id) htest_child1_ctest_cust_id_fkey IN public.htest_child1(ctest_cust_id) REFERENCES htest(new_id) diff describe.c_orig describe.c1109c1109,1110 *result6 = NULL;--- *result6 = NULL, *result7 = NULL;1114a1116 refof_count = 0,1247,1248c1249,1265 footers = pg_malloc_zero((index_count + check_count + rule_count + trigger_count + foreignkey_count + inherits_count + 7 + 1) * sizeof(*footers));--- /* reference_by count */ printfPQExpBuffer(buf,SELECT c.conname,n.nspname,p2.relname,pg_catalog.pg_get_constraintdef(c.oid, true)\n FROM pg_catalog.pg_class p, pg_catalog.pg_constraint c, pg_catalog.pg_class p2 \n ,pg_catalog.pg_namespace n WHERE p.oid = '%s' AND c.confrelid = '%s'\n AND c.conrelid = p2.oid AND n.oid =p2.relnamespace, oid,oid); result7 = PSQLexec(buf.data, false); if (!result7) goto error_return; else refof_count = PQntuples(result7); footers = pg_malloc_zero((index_count + check_count + rule_count + trigger_count + foreignkey_count + inherits_count + refof_count + 7 + 1) * sizeof(*footers));1483a1501,1526 /* print reference count details */ if (refof_count 0) { printfPQExpBuffer(buf, _(Refrenced by :)); footers[count_footers++] = pg_strdup(buf.data); for (i = 0; i refof_count; i++) { const char *refbydef; const char *usingpos; printfPQExpBuffer(buf, _( \%s\ IN %s.%s), PQgetvalue(result7,i,0), PQgetvalue(result7,i,1), PQgetvalue(result7,i,2)); /* Everything after FOREIGN KEY is echoed verbatim */ refbydef = PQgetvalue(result7, i, 3); usingpos = strstr(refbydef, FOREIGN KEY ); if (usingpos) refbydef = usingpos + 12; appendPQExpBuffer(buf, %s,refbydef); footers[count_footers++] = pg_strdup(buf.data); } } _ Tried the new MSN Messenger? It’s cool! Download now. http://messenger.msn.com/Download/Default.aspx?mkt=en-in
Re: [PATCHES] Reference by output in : \d table_name
On Mon, Feb 25, 2008 at 5:05 PM, kenneth d'souza [EMAIL PROTECTED] wrote: Refrenced by : htest_child_ctest_cust_id_fkey IN public.htest_child(ctest_cust_id) REFERENCES htest(new_id) htest_child1_ctest_cust_id_fkey IN public.htest_child1(ctest_cust_id) REFERENCES htest(new_id) Very cool! Cheers, BJ ---(end of broadcast)--- TIP 7: You can help support the PostgreSQL project by donating at http://www.postgresql.org/about/donate