On Wed, Nov 24, 2010 at 12:07 AM, Robert Haas <robertmh...@gmail.com> wrote:
> Per previous threats, I spent some time tonight running oprofile
> (using the directions Tom Lane was foolish enough to provide me back
> in May).  I took testlibpq.c and hacked it up to just connect to the
> server and then disconnect in a tight loop without doing anything
> useful, hoping to measure the overhead of starting up a new
> connection.

Oh, right: attachments.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
CPU: AMD64 family10, speed 2200 MHz (estimated)
Counted CPU_CLK_UNHALTED events (Cycles outside of halt state) with a unit mask 
of 0x00 (No unit mask) count 100000
samples  %        image name               symbol name
120899   18.0616  postgres                 AtProcExit_Buffers
56891     8.4992  libc-2.11.2.so           memset
30987     4.6293  libc-2.11.2.so           memcpy
26944     4.0253  postgres                 hash_search_with_hash_value
26554     3.9670  postgres                 AllocSetAlloc
20407     3.0487  libc-2.11.2.so           _int_malloc
17269     2.5799  libc-2.11.2.so           fread
13005     1.9429  ld-2.11.2.so             do_lookup_x
11850     1.7703  ld-2.11.2.so             _dl_fixup
10194     1.5229  libc-2.11.2.so           _IO_file_xsgetn
10087     1.5069  postgres                 MemoryContextAllocZero
9143      1.3659  ld-2.11.2.so             strcmp
8957      1.3381  postgres                 load_relcache_init_file
7132      1.0655  postgres                 fmgr_info_cxt_security
5630      0.8411  libc-2.11.2.so           vfprintf
5029      0.7513  ld-2.11.2.so             _dl_lookup_symbol_x
4997      0.7465  postgres                 _bt_getroot
3935      0.5879  libc-2.11.2.so           memcmp
3874      0.5788  postgres                 hash_seq_search
3718      0.5554  postgres                 LWLockAcquire
3666      0.5477  postgres                 guc_name_compare
3457      0.5165  libc-2.11.2.so           __strlen_sse2
3297      0.4926  postgres                 load_relmap_file
3175      0.4743  libc-2.11.2.so           malloc
3170      0.4736  postgres                 LockAcquireExtended
3139      0.4689  postgres                 hash_any
3113      0.4651  postgres                 MemoryContextAlloc
2946      0.4401  postgres                 _bt_compare
2936      0.4386  postgres                 index_getnext
2885      0.4310  ld-2.11.2.so             _dl_sort_fini
2873      0.4292  libc-2.11.2.so           _int_free
2619      0.3913  postgres                 MemoryContextCreate
2579      0.3853  ld-2.11.2.so             check_match.12146
2485      0.3712  postgres                 heap_page_prune_opt
2457      0.3671  postgres                 LWLockRelease
2438      0.3642  postgres                 CreateTemplateTupleDesc
2322      0.3469  ld-2.11.2.so             _dl_fini
2301      0.3438  postgres                 set_config_option
2253      0.3366  postgres                 _bt_first
2225      0.3324  postgres                 PinBuffer
2140      0.3197  postgres                 BeginReportingGUCOptions
2091      0.3124  postgres                 _bt_preprocess_keys
2085      0.3115  libc-2.11.2.so           _IO_vfscanf
2051      0.3064  postgres                 element_alloc
1962      0.2931  postgres                 ServerLoop
1936      0.2892  postgres                 CreateTupleDescCopyConstr
1884      0.2815  libc-2.11.2.so           __strcpy_sse2
1846      0.2758  libkrb5.so.3.3           /lib64/libkrb5.so.3.3
1801      0.2691  postgres                 FunctionCall2
1797      0.2685  postgres                 hash_create
1782      0.2662  postgres                 PgstatCollectorMain
1761      0.2631  postgres                 _bt_checkpage
1728      0.2582  postgres                 AllocSetFree
1597      0.2386  libselinux.so.1          /lib64/libselinux.so.1
1579      0.2359  libc-2.11.2.so           _IO_default_xsputn
1543      0.2305  libc-2.11.2.so           free
1531      0.2287  postgres                 SearchCatCache
1528      0.2283  postgres                 BuildHardcodedDescriptor
1506      0.2250  libc-2.11.2.so           strchrnul
1475      0.2204  postgres                 _bt_checkkeys
1457      0.2177  postgres                 ResourceOwnerForgetRelationRef
1451      0.2168  ld-2.11.2.so             _dl_runtime_resolve
1443      0.2156  postgres                 InitCatCache
1443      0.2156  postgres                 hash_search
1382      0.2065  ld-2.11.2.so             _dl_name_match_p
1360      0.2032  postgres                 PostgresMain
1347      0.2012  postgres                 pgstat_report_stat
1342      0.2005  libssl.so.1.0.0b         /usr/lib64/libssl.so.1.0.0b
1340      0.2002  postgres                 systable_beginscan
1311      0.1959  libgssapi_krb5.so.2.2    /lib64/libgssapi_krb5.so.2.2
1254      0.1873  postgres                 errstart
1247      0.1863  libc-2.11.2.so           __strncmp_sse2
1245      0.1860  postgres                 ReadBuffer_common
1244      0.1858  libxml2.so.2.7.6         /usr/lib64/libxml2.so.2.7.6
1199      0.1791  libc-2.11.2.so           fork
1164      0.1739  libc-2.11.2.so           _IO_sgetn
1164      0.1739  postgres                 pgstat_initstats
1163      0.1737  postgres                 AllocSetContextCreate
1158      0.1730  postgres                 ProcessStartupPacket
1153      0.1723  postgres                 LockRelease
1130      0.1688  libc-2.11.2.so           mempcpy
1124      0.1679  postgres                 InitCatalogCache
1120      0.1673  libk5crypto.so.3.1       /lib64/libk5crypto.so.3.1
1117      0.1669  postgres                 HeapTupleSatisfiesNow
1110      0.1658  postgres                 oid_hash
1101      0.1645  postgres                 InitPostgres
1069      0.1597  postgres                 nocachegetattr
1061      0.1585  postgres                 RelationBuildDesc
1059      0.1582  postgres                 tag_hash
1057      0.1579  libc-2.11.2.so           bsearch
1054      0.1575  postgres                 hash_uint32
1010      0.1509  postgres                 SIGetDataEntries
955       0.1427  postgres                 RelationCacheInitializePhase3
953       0.1424  postgres                 get_tabstat_entry
932       0.1392  postgres                 InitProcess
926       0.1383  libc-2.11.2.so           malloc_consolidate
882       0.1318  libc-2.11.2.so           __GI_____strtoll_l_internal
881       0.1316  libcrypto.so.1.0.0b      /lib64/libcrypto.so.1.0.0b
864       0.1291  postgres                 RelationMapOidToFilenode
863       0.1289  postgres                 IsSharedRelation
845       0.1262  postgres                 RecoveryInProgress
840       0.1255  postgres                 RelationInitPhysicalAddr
829       0.1238  libc-2.11.2.so           snprintf
828       0.1237  libc-2.11.2.so           _wordcopy_fwd_aligned
826       0.1234  postgres                 ReadBufferExtended
797       0.1191  postgres                 reaper
786       0.1174  libc-2.11.2.so           random_r
783       0.1170  postgres                 RelationInitLockInfo
764       0.1141  libc-2.11.2.so           _IO_str_init_static_internal
761       0.1137  postgres                 LockReleaseAll
760       0.1135  libc-2.11.2.so           _IO_setb
760       0.1135  postgres                 ReportGUCOption
753       0.1125  postgres                 LockBuffer
744       0.1111  libkrb5support.so.0.1    /lib64/libkrb5support.so.0.1
741       0.1107  libc-2.11.2.so           sigprocmask
740       0.1106  postgres                 DLAddHead
733       0.1095  libc-2.11.2.so           _getopt_internal_r
728       0.1088  postgres                 CatalogCacheInitializeCache
724       0.1082  postgres                 _bt_binsrch
708       0.1058  libc-2.11.2.so           _IO_un_link
707       0.1056  libc-2.11.2.so           close
707       0.1056  postgres                 btoidcmp
699       0.1044  libcom_err.so.2.1        /lib64/libcom_err.so.2.1
690       0.1031  libc-2.11.2.so           recv
687       0.1026  libc-2.11.2.so           vsnprintf
668       0.0998  libc-2.11.2.so           __errno_location
660       0.0986  postgres                 pgstat_bestart
659       0.0985  postgres                 CleanUpLock
654       0.0977  libc-2.11.2.so           _IO_file_underflow@@GLIBC_2.2.5
654       0.0977  postgres                 smgropen
651       0.0973  libz.so.1.2.3            /lib64/libz.so.1.2.3
643       0.0961  libc-2.11.2.so           __strstr_sse2
639       0.0955  postgres                 internal_flush
630       0.0941  postgres                 StartTransactionCommand
627       0.0937  postgres                 fmgr_info_cxt
626       0.0935  postgres                 _bt_fix_scankey_strategy
626       0.0935  postgres                 btrescan
613       0.0916  postgres                 _bt_readpage
610       0.0911  postgres                 _bt_getbuf
608       0.0908  libc-2.11.2.so           fclose@@GLIBC_2.2.5
608       0.0908  postgres                 strlcpy
597       0.0892  postgres                 LockRelationOid
595       0.0889  postgres                 hba_getauthmethod
587       0.0877  libc-2.11.2.so           strdup
587       0.0877  postgres                 AfterTriggerBeginXact
587       0.0877  postgres                 _ShowOption
586       0.0875  libc-2.11.2.so           _IO_file_fopen@@GLIBC_2.2.5
586       0.0875  postgres                 CommitTransaction
571       0.0853  postgres                 RelationIncrementReferenceCount
568       0.0849  postgres                 ResourceOwnerEnlargeRelationRefs
566       0.0846  libc-2.11.2.so           strtok
566       0.0846  postgres                 secure_read
563       0.0841  libpthread-2.11.2.so     _pthread_cleanup_push_defer
556       0.0831  postgres                 _bt_relandgetbuf
547       0.0817  postgres                 _bt_moveright
546       0.0816  postgres                 PathNameOpenFile
541       0.0808  libc-2.11.2.so           _IO_no_init
540       0.0807  libc-2.11.2.so           memmove
540       0.0807  libc-2.11.2.so           time
539       0.0805  postgres                 index_getprocinfo
538       0.0804  postgres                 _bt_mark_scankey_required
531       0.0793  postgres                 pg_char_to_encname_struct
525       0.0784  libc-2.11.2.so           __strcmp_sse2
525       0.0784  libc-2.11.2.so           __unregister_atfork
517       0.0772  libc-2.11.2.so           _IO_flush_all_lockp
505       0.0754  postgres                 ClosePostmasterPorts
505       0.0754  postgres                 process_postgres_switches
503       0.0751  postgres                 relation_open
493       0.0737  libc-2.11.2.so           open
491       0.0734  postgres                 pg_perm_setlocale
484       0.0723  postgres                 RelationGetIndexScan
483       0.0722  libc-2.11.2.so           _IO_link_in
482       0.0720  postgres                 _bt_search
478       0.0714  postgres                 fmgr_info_copy
475       0.0710  postgres                 CleanupTempFiles
472       0.0705  postgres                 IsAutoVacuumLauncherProcess
472       0.0705  postgres                 prepare_for_client_read
463       0.0692  libc-2.11.2.so           getpid
462       0.0690  libc-2.11.2.so           calloc
462       0.0690  postgres                 heap_open
460       0.0687  postgres                 RelationInitIndexAccessInfo
454       0.0678  postgres                 internal_putbytes
452       0.0675  libc-2.11.2.so           setitimer
448       0.0669  postgres                 LookupOpclassInfo
444       0.0663  ld-2.11.2.so             _wordcopy_bwd_aligned
443       0.0662  postgres                 DirectFunctionCall1
439       0.0656  libc-2.11.2.so           munmap
437       0.0653  postgres                 BufTableLookup
434       0.0648  postgres                 AllocateFile
434       0.0648  postgres                 systable_getnext
430       0.0642  postgres                 ValidatePgVersion
429       0.0641  postgres                 enable_sig_alarm
428       0.0639  postgres                 oideq
422       0.0630  postgres                 ReceiveSharedInvalidMessages
420       0.0627  postgres                 AssignPostmasterChildSlot
420       0.0627  postgres                 ReleaseBuffer
417       0.0623  libkeyutils-1.2.so       /lib64/libkeyutils-1.2.so
417       0.0623  postgres                 guc_var_compare
416       0.0621  libc-2.11.2.so           fopen@@GLIBC_2.2.5
416       0.0621  postgres                 shmem_exit
413       0.0617  postgres                 DLInitElem
413       0.0617  postgres                 heapgettup
412       0.0616  libc-2.11.2.so           __add_to_environ
411       0.0614  postgres                 RelationDecrementReferenceCount
409       0.0611  libc-2.11.2.so           random
403       0.0602  postgres                 RelationIdGetRelation
401       0.0599  postgres                 elog_start
400       0.0598  libc-2.11.2.so           __underflow
399       0.0596  libc-2.11.2.so           __default_morecore
399       0.0596  libc-2.11.2.so           setlocale
393       0.0587  libc-2.11.2.so           __sigsetjmp
390       0.0583  postgres                 ClientAuthentication
387       0.0578  libc-2.11.2.so           _IO_file_close_it@@GLIBC_2.2.5
386       0.0577  postgres                 ResourceOwnerForgetBuffer
386       0.0577  postgres                 index_open
385       0.0575  postgres                 pfree
384       0.0574  libc-2.11.2.so           ptmalloc_unlock_all
378       0.0565  libc-2.11.2.so           sbrk
371       0.0554  postgres                 ResourceOwnerEnlargeBuffers
371       0.0554  postgres                 hash_seq_init
367       0.0548  postgres                 ShowTransactionState
366       0.0547  postgres                 BufTableHashCode
364       0.0544  postgres                 MemoryContextStrdup
361       0.0539  libc-2.11.2.so           sigemptyset
361       0.0539  postgres                 index_endscan
359       0.0536  postgres                 truncate_identifier
357       0.0533  postgres                 GetSnapshotData
355       0.0530  postgres                 index_beginscan_internal
354       0.0529  postgres                 UnpinBuffer
350       0.0523  libc-2.11.2.so           _itoa_word
350       0.0523  libc-2.11.2.so           srandom_r
347       0.0518  libc-2.11.2.so           send
346       0.0517  postgres                 BasicOpenFile
345       0.0515  postgres                 lcons_oid
344       0.0514  libc-2.11.2.so           __libc_sigaction
341       0.0509  postgres                 ReadBuffer
340       0.0508  libc-2.11.2.so           poll
337       0.0503  postgres                 GetRedoRecPtr
336       0.0502  libc-2.11.2.so           __libc_fini
335       0.0500  libc-2.11.2.so           read
335       0.0500  postgres                 btgettuple
328       0.0490  postgres                 RelationCacheInitializePhase2
327       0.0489  postgres                 list_member_oid
326       0.0487  libc-2.11.2.so           __read_nocancel
326       0.0487  postgres                 ReindexIsProcessingIndex
326       0.0487  postgres                 ReleaseAndReadBuffer
326       0.0487  postgres                 pgstat_initialize
324       0.0484  libc-2.11.2.so           mmap
323       0.0483  postgres                 call_string_assign_hook
322       0.0481  postgres                 set_spins_per_delay
321       0.0480  libc-2.11.2.so           fflush
321       0.0480  postgres                 MemoryContextDelete
317       0.0474  postgres                 ResourceOwnerReleaseInternal
316       0.0472  libc-2.11.2.so           _IO_file_init@@GLIBC_2.2.5
316       0.0472  postgres                 btbeginscan
315       0.0471  postgres                 UnlockRelationId
313       0.0468  postgres                 SearchSysCache
313       0.0468  postgres                 pgstat_beshutdown_hook
312       0.0466  postgres                 SetConfigOption
311       0.0465  postgres                 SharedInvalBackendInit
306       0.0457  postgres                 initStringInfo
305       0.0456  postgres                 systable_endscan
301       0.0450  postgres                 ScanKeyEntryInitializeWithInfo
301       0.0450  postgres                 seg_alloc
300       0.0448  libc-2.11.2.so           _IO_cleanup
300       0.0448  postgres                 assign_session_authorization
296       0.0442  libc-2.11.2.so           __ctype_b_loc
296       0.0442  postgres                 DisableNotifyInterrupt
295       0.0441  libc-2.11.2.so           __cxa_finalize
295       0.0441  libpthread-2.11.2.so     __reclaim_stacks
294       0.0439  postgres                 set_ps_display
293       0.0438  libc-2.11.2.so           ____strtoull_l_internal
292       0.0436  ld-2.11.2.so             memmove
291       0.0435  postgres                 FunctionCall3
291       0.0435  postgres                 TransactionIdPrecedes
291       0.0435  postgres                 btendscan
290       0.0433  libnss_files-2.11.2.so   __do_global_dtors_aux
289       0.0432  postgres                 pqsignal
288       0.0430  postgres                 initialize_acl
287       0.0429  postgres                 IsAutoVacuumWorkerProcess
286       0.0427  postgres                 SetClientEncoding
282       0.0421  postgres                 pq_putmessage
281       0.0420  libpthread-2.11.2.so     pthread_mutex_lock
280       0.0418  libc-2.11.2.so           _IO_list_unlock
279       0.0417  postgres                 LockTagHashCode
278       0.0415  postgres                 config_enum_lookup_by_value
278       0.0415  postgres                 pg_strncasecmp
276       0.0412  postgres                 mdnblocks
273       0.0408  postgres                 AtStart_GUC
273       0.0408  postgres                 ResourceOwnerRememberRelationRef
272       0.0406  libc-2.11.2.so           __select_nocancel
272       0.0406  postgres                 BackendInitialize
272       0.0406  postgres                 PreCommit_Notify
271       0.0405  libc-2.11.2.so           exit
271       0.0405  postgres                 GetCurrentSubTransactionId
269       0.0402  postgres                 FreeDesc
268       0.0400  libc-2.11.2.so           _IO_file_doallocate
268       0.0400  postgres                 RelationCacheInitialize
268       0.0400  postgres                 ReleaseResources_hash
266       0.0397  postgres                 CommitTransactionCommand
265       0.0396  libc-2.11.2.so           fscanf
265       0.0396  postgres                 index_rescan
263       0.0393  postgres                 ApplySetting
262       0.0391  libpthread-2.11.2.so     pthread_rwlock_wrlock
258       0.0385  libc-2.11.2.so           llseek
257       0.0384  libresolv-2.11.2.so      __do_global_dtors_aux
256       0.0382  libm-2.11.2.so           __do_global_dtors_aux
256       0.0382  postgres                 CatalogCacheComputeHashValue
255       0.0381  postgres                 get_role_oid
253       0.0378  postgres                 AtCommit_Notify
253       0.0378  postgres                 LockAcquire
253       0.0378  postgres                 pgstat_report_xact_timestamp
252       0.0376  postgres                 nameeq
250       0.0373  postgres                 GetTransactionSnapshot
248       0.0370  postgres                 ProcQueueInit
246       0.0368  postgres                 GetCurrentTimestamp
245       0.0366  libc-2.11.2.so           _getopt_internal
243       0.0363  postgres                 CatalogCacheCreateEntry
242       0.0362  libc-2.11.2.so           vsprintf
242       0.0362  postgres                 AtEOXact_ComboCid
242       0.0362  postgres                 SHMQueueElemInit
240       0.0359  postgres                 ReleaseCatCache
240       0.0359  postgres                 get_hash_value
238       0.0356  postgres                 CreateCacheMemoryContext
238       0.0356  postgres                 GetCurrentTransactionNestLevel
237       0.0354  libc-2.11.2.so           semctl
236       0.0353  postgres                 PreCommit_on_commit_actions
235       0.0351  libc-2.11.2.so           ptmalloc_unlock_all2
235       0.0351  postgres                 extractRelOptions
234       0.0350  postgres                 CleanupInvalidationState
234       0.0350  postgres                 RelationMapInitialize
232       0.0347  postgres                 smgrGetPendingDeletes
231       0.0345  postgres                 InitPlanCache
229       0.0342  libc-2.11.2.so           brk
229       0.0342  postgres                 ProcKill
229       0.0342  postgres                 parse_bool_with_len
228       0.0341  libc-2.11.2.so           _IO_old_init
228       0.0341  postgres                 EnablePortalManager
228       0.0341  postgres                 RemoveLocalLock
227       0.0339  libc-2.11.2.so           select
227       0.0339  postgres                 SHMQueueInit
227       0.0339  postgres                 enlargeStringInfo
226       0.0338  postgres                 AfterTriggerEndXact
226       0.0338  postgres                 mdopen
224       0.0335  libc-2.11.2.so           putenv
224       0.0335  postgres                 find_option
223       0.0333  libc-2.11.2.so           getopt
220       0.0329  postgres                 elog_finish
220       0.0329  postgres                 pq_beginmessage
219       0.0327  postgres                 InitBufferPoolBackend
219       0.0327  postgres                 PGSemaphoreReset
219       0.0327  postgres                 pg_encoding_max_length
218       0.0326  libpthread-2.11.2.so     sem_destroy@@GLIBC_2.2.5
218       0.0326  postgres                 SetDatabaseEncoding
217       0.0324  libpthread-2.11.2.so     _fini
216       0.0323  libc-2.11.2.so           getsockname
216       0.0323  libm-2.11.2.so           _fini
215       0.0321  postgres                 init_ps_display
213       0.0318  libnss_files-2.11.2.so   _fini
212       0.0317  postgres                 InitializeSearchPath
211       0.0315  postgres                 InitDeadLockChecking
211       0.0315  postgres                 btnamecmp
211       0.0315  postgres                 parse_bool
209       0.0312  libdl-2.11.2.so          _fini
209       0.0312  libresolv-2.11.2.so      _fini
209       0.0312  postgres                 ResourceOwnerEnlargeCatCacheRefs
207       0.0309  postgres                 AtEOXact_MultiXact
207       0.0309  postgres                 ProcSignalInit
207       0.0309  postgres                 disable_sig_alarm
207       0.0309  postgres                 heap_getnext
206       0.0308  postgres                 client_read_ended
206       0.0308  postgres                 heapgetpage
205       0.0306  postgres                 ResourceOwnerCreate
205       0.0306  postgres                 pq_getbytes
204       0.0305  postgres                 CountChildren
204       0.0305  postgres                 on_exit_reset
202       0.0302  postgres                 int2gt
201       0.0300  postgres                 CacheRegisterSyscacheCallback
201       0.0300  postgres                 EnableNotifyInterrupt
201       0.0300  postgres                 index_close
201       0.0300  postgres                 pg_get_timezone_name
200       0.0299  libc-2.11.2.so           _int_realloc
200       0.0299  libc-2.11.2.so           srandom
199       0.0297  postgres                 ProcArrayEndTransaction
197       0.0294  libc-2.11.2.so           waitpid
197       0.0294  postgres                 InitBufferPoolAccess
196       0.0293  postgres                 _bt_steppage
194       0.0290  postgres                 SHMQueueInsertBefore
193       0.0288  postgres                 appendBinaryStringInfo
192       0.0287  libc-2.11.2.so           vfscanf
191       0.0285  postgres                 AcceptInvalidationMessages
191       0.0285  postgres                 AfterTriggerFireDeferred
191       0.0285  postgres                 RelationMapInitializePhase2
190       0.0284  postgres                 proc_exit_prepare
189       0.0282  postgres                 VirtualXactLockTableInsert
187       0.0279  postgres                 pg_getnameinfo_all
186       0.0278  postgres                 pgstat_get_db_entry
184       0.0275  postgres                 PostmasterRandom
179       0.0267  postgres                 EnableCatchupInterrupt
179       0.0267  postgres                 InSecurityRestrictedOperation
178       0.0266  postgres                 ResourceOwnerForgetCatCacheRef
175       0.0261  postgres                 DebugFileOpen
175       0.0261  postgres                 ProcArrayAdd
174       0.0260  postgres                 LockCheckConflicts
173       0.0258  libc-2.11.2.so           gettimeofday
173       0.0258  postgres                 pq_sendint
172       0.0257  postgres                 InitFileAccess
172       0.0257  postgres                 guc_strdup
172       0.0257  postgres                 heap_copytuple_with_tuple
171       0.0255  libc-2.11.2.so           _IO_file_finish@@GLIBC_2.2.5
171       0.0255  libc-2.11.2.so           realloc
170       0.0254  postgres                 index_beginscan
170       0.0254  postgres                 process_startup_options
168       0.0251  postgres                 AbortOutOfAnyTransaction
168       0.0251  postgres                 ShutdownPostgres
167       0.0249  libc-2.11.2.so           _IO_file_close
167       0.0249  postgres                 LogChildExit
167       0.0249  postgres                 on_shmem_exit
165       0.0247  postgres                 pq_recvbuf
164       0.0245  postgres                 SHMQueueDelete
163       0.0244  postgres                 IndexScanEnd
163       0.0244  postgres                 relpathbackend
162       0.0242  postgres                 AbortBufferIO
161       0.0241  libc-2.11.2.so           __fopen_internal
159       0.0238  postgres                 ReadyForQuery
159       0.0238  postgres                 StreamConnection
159       0.0238  postgres                 timestamptz_to_time_t
158       0.0236  postgres                 relation_close
156       0.0233  libc-2.11.2.so           __close_nocancel
156       0.0233  postgres                 ResourceOwnerRememberBuffer
155       0.0232  postgres                 pg_split_opts
154       0.0230  libc-2.11.2.so           _IO_doallocbuf
154       0.0230  postgres                 SHMQueueNext
154       0.0230  postgres                 smgrsetowner
150       0.0224  libc-2.11.2.so           _exit
150       0.0224  postgres                 initscan
150       0.0224  postgres                 pg_server_to_client
150       0.0224  postgres                 pq_sendstring
150       0.0224  postgres                 set_string_field
149       0.0223  postgres                 smgrinit
142       0.0212  postgres                 _bt_next
141       0.0211  postgres                 FileSeek
141       0.0211  postgres                 IsTransactionOrTransactionBlock
139       0.0208  libc-2.11.2.so           sigdelset
138       0.0206  postgres                 RelationParseRelOptions
138       0.0206  postgres                 heap_beginscan_internal
137       0.0205  libc-2.11.2.so           _IO_file_stat
137       0.0205  libc-2.11.2.so           __fxstat64
137       0.0205  libc-2.11.2.so           access
137       0.0205  postgres                 GetDatabaseTuple
137       0.0205  postgres                 ProcArrayRemove
135       0.0202  postgres                 secure_write
134       0.0200  libpthread-2.11.2.so     __do_global_dtors_aux
133       0.0199  libc-2.11.2.so           _IO_file_read
129       0.0193  postgres                 ProcessCompletedNotifies
129       0.0193  postgres                 pg_encoding_mbcliplen
129       0.0193  postgres                 pqinitmask
128       0.0191  libc-2.11.2.so           _IO_file_sync@@GLIBC_2.2.5
126       0.0188  libc-2.11.2.so           sprintf
126       0.0188  postgres                 pq_init
123       0.0184  postgres                 pq_endmessage
121       0.0181  libc-2.11.2.so           strtol
121       0.0181  postgres                 AtEOXact_LargeObject
121       0.0181  postgres                 __do_global_dtors_aux
120       0.0179  postgres                 ScanPgRelation
118       0.0176  postgres                 InitializeSessionUserId
117       0.0175  postgres                 heap_copytuple
116       0.0173  postgres                 AllocSetDelete
116       0.0173  postgres                 secure_close
115       0.0172  postgres                 DLRemove
115       0.0172  postgres                 GrantLock
113       0.0169  libc-2.11.2.so           _IO_iter_begin
113       0.0169  libdl-2.11.2.so          fini
112       0.0167  postgres                 PostmasterStateMachine
111       0.0166  libc-2.11.2.so           _IO_unsave_markers
111       0.0166  postgres                 GetDatabaseEncodingName
109       0.0163  postgres                 AtEOXact_Inval
109       0.0163  postgres                 DynaHashAlloc
108       0.0161  postgres                 _bt_freestack
108       0.0161  postgres                 proc_exit
107       0.0160  postgres                 CleanupProcSignalState
106       0.0158  postgres                 assign_client_encoding
106       0.0158  postgres                 superuser_arg
105       0.0157  postgres                 fork_process
104       0.0155  postgres                 show_session_authorization
102       0.0152  postgres                 AtEarlyCommit_Snapshot
102       0.0152  postgres                 ConnFree
102       0.0152  postgres                 InitXLOGAccess
101       0.0151  postgres                 GetDatabasePath
101       0.0151  postgres                 LockWaitCancel
101       0.0151  postgres                 ResourceOwnerDelete
98        0.0146  libdl-2.11.2.so          __do_global_dtors_aux
97        0.0145  postgres                 GetNextLocalTransactionId
95        0.0142  libc-2.11.2.so           strnlen
95        0.0142  postgres                 MarkPostmasterChildActive
94        0.0140  postgres                 AtEOXact_RelationMap
94        0.0140  postgres                 AtEOXact_SPI
94        0.0140  postgres                 RelationMapInitializePhase3
92        0.0137  postgres                 GetSysCacheOid
91        0.0136  postgres                 CommitHoldablePortals
91        0.0136  postgres                 _fini
91        0.0136  postgres                 show_timezone
90        0.0134  libc-2.11.2.so           sigaction
90        0.0134  postgres                 GetPgIndexDescriptor
89        0.0133  postgres                 ResourceOwnerRelease
89        0.0133  postgres                 pgstat_send_tabstat
89        0.0133  postgres                 pq_getmessage
87        0.0130  libc-2.11.2.so           accept
85        0.0127  postgres                 AtEOXact_GUC
85        0.0127  postgres                 CacheRegisterRelcacheCallback
84        0.0125  postgres                 AtEOXact_Namespace
84        0.0125  postgres                 FreeFile
84        0.0125  postgres                 GetSessionUserId
84        0.0125  postgres                 TimestampDifferenceExceeds
84        0.0125  postgres                 pq_getbyte
83        0.0124  libc-2.11.2.so           _IO_switch_to_get_mode
83        0.0124  postgres                 ScanKeyInit
83        0.0124  postgres                 TransactionBlockStatusCode
82        0.0123  postgres                 TransactionStartedDuringRecovery
81        0.0121  libc-2.11.2.so           __fopen_maybe_mmap
81        0.0121  postgres                 AtEOXact_PgStat
81        0.0121  postgres                 AtStart_Inval
81        0.0121  postgres                 pq_sendbyte
81        0.0121  postgres                 process_local_preload_libraries
80        0.0120  postgres                 IsAbortedTransactionBlockState
79        0.0118  libpthread-2.11.2.so     pthread_mutex_unlock
79        0.0118  postgres                 LockSharedObject
79        0.0118  postgres                 ReleasePostmasterChildSlot
78        0.0117  libc-2.11.2.so           __uflow
77        0.0115  postgres                 InLocalUserIdChange
77        0.0115  postgres                 mdinit
75        0.0112  postgres                 afterTriggerMarkEvents
75        0.0112  postgres                 hashname
74        0.0111  postgres                 AtCommit_Portals
73        0.0109  postgres                 InitializeClientEncoding
73        0.0109  postgres                 TimestampDifference
73        0.0109  postgres                 hash_seq_term
71        0.0106  postgres                 FunctionCall1
71        0.0106  postgres                 pg_utf_mblen
71        0.0106  postgres                 resetStringInfo
70        0.0105  postgres                 AtEOXact_HashTables
70        0.0105  postgres                 RemoveProcFromArray
70        0.0105  postgres                 load_libraries
69        0.0103  postgres                 AtProcExit_LocalBuffers
69        0.0103  postgres                 SetSessionAuthorization
68        0.0102  postgres                 superuser
66        0.0099  postgres                 heap_getsysattr
65        0.0097  libc-2.11.2.so           __open_nocancel
65        0.0097  libc-2.11.2.so           __strchr_sse2
65        0.0097  postgres                 _mdnblocks
65        0.0097  postgres                 heap_beginscan
64        0.0096  postgres                 heap_endscan
63        0.0094  postgres                 ProcessInvalidationMessagesMulti
62        0.0093  postgres                 hashoid
62        0.0093  postgres                 pq_close
61        0.0091  postgres                 IsTransactionState
61        0.0091  postgres                 PageGetHeapFreeSpace
60        0.0090  libc-2.11.2.so           ptmalloc_lock_all
60        0.0090  postgres                 AtEOXact_Snapshot
60        0.0090  postgres                 InitProcessPhase2
60        0.0090  postgres                 RelationGetNumberOfBlocks
58        0.0087  postgres                 AtEOXact_on_commit_actions
58        0.0087  postgres                 UnlockBuffers
58        0.0087  postgres                 new_list
58        0.0087  postgres                 pg_valid_client_encoding
58        0.0087  postgres                 pq_flush
57        0.0085  libpthread-2.11.2.so     _pthread_cleanup_pop_restore
57        0.0085  postgres                 DLMoveToFront
57        0.0085  postgres                 pgstat_clear_snapshot
55        0.0082  libc-2.11.2.so           setsid
55        0.0082  postgres                 AtEOXact_Files
55        0.0082  postgres                 sendAuthRequest
54        0.0081  libpthread-2.11.2.so     pthread_rwlock_unlock
54        0.0081  postgres                 pg_char_to_encoding
53        0.0079  libc-2.11.2.so           strtoul
53        0.0079  postgres                 GetCurrentTransactionStopTimestamp
53        0.0079  postgres                 on_proc_exit
52        0.0078  libc-2.11.2.so           _IO_list_lock
52        0.0078  postgres                 pg_mbcliplen
51        0.0076  libc-2.11.2.so           _IO_default_finish
51        0.0076  postgres                 IpcSemaphoreInitialize
50        0.0075  libc-2.11.2.so           __restore_rt
48        0.0072  postgres                 pgstat_report_activity
44        0.0066  libc-2.11.2.so           _IO_default_uflow
44        0.0066  postgres                 AtProcExit_Files
44        0.0066  postgres                 LWLockReleaseAll
43        0.0064  postgres                 ResourceOwnerNewParent
43        0.0064  postgres                 SetDatabasePath
42        0.0063  postgres                 BaseInit
42        0.0063  postgres                 smgrnblocks
40        0.0060  libc-2.11.2.so           sigfillset
40        0.0060  postgres                 MarkPostmasterChildInactive
39        0.0058  postgres                 GetCurrentCommandId
39        0.0058  postgres                 atexit_callback
38        0.0057  libc-2.11.2.so           _IO_sputbackc
38        0.0057  libc-2.11.2.so           __sigjmp_save
38        0.0057  postgres                 BufferGetBlockNumber
35        0.0052  postgres                 pgstat_send
34        0.0051  postgres                 AtEOXact_RelationCache
34        0.0051  postgres                 StreamClose
33        0.0049  postgres                 fmgr_info
32        0.0048  postgres                 AllocSetInit
30        0.0045  postgres                 update_spins_per_delay
25        0.0037  postgres                 UnlockReleaseBuffer
24        0.0036  postgres                 ResourceOwnerRememberCatCacheRef
24        0.0036  postgres                 canAcceptConnections
22        0.0033  postgres                 DisableCatchupInterrupt
21        0.0031  postgres                 BgBufferSync
21        0.0031  postgres                 RelationClose
21        0.0031  postgres                 XLogBackgroundFlush
21        0.0031  postgres                 smgrDoPendingDeletes
20        0.0030  libc-2.11.2.so           __lseek_nocancel
20        0.0030  postgres                 GetCurrentStatementStartTimestamp
20        0.0030  postgres                 MemoryContextDeleteChildren
18        0.0027  postgres                 MemoryContextResetAndDeleteChildren
17        0.0025  postgres                 pgstat_report_appname
16        0.0024  libc-2.11.2.so           __accept_nocancel
16        0.0024  postgres                 AllocSetReset
15        0.0022  postgres                 pg_usleep
14        0.0021  postgres                 GetUserId
13        0.0019  postgres                 ProcReleaseLocks
13        0.0019  postgres                 SyncOneBuffer
12        0.0018  postgres                 WalWriterMain
12        0.0018  postgres                 btint2cmp
11        0.0016  libc-2.11.2.so           _IO_iter_end
11        0.0016  libc-2.11.2.so           _IO_list_resetlock
11        0.0016  libc-2.11.2.so           __strtol_internal
11        0.0016  libc-2.11.2.so           getppid
9         0.0013  libc-2.11.2.so           _IO_iter_file
9         0.0013  postgres                 AtEOXact_Buffers
9         0.0013  postgres                 CheckArchiveTimeout
6        9.0e-04  postgres                 GetUserIdAndSecContext
5        7.5e-04  postgres                 AbsorbFsyncRequests
4        6.0e-04  postgres                 pgstat_send_bgwriter
3        4.5e-04  postgres                 BackgroundWriterMain
3        4.5e-04  postgres                 StrategySyncStart
3        4.5e-04  postgres                 _bt_relbuf
2        3.0e-04  libc-2.11.2.so           _IO_iter_next
2        3.0e-04  postgres                 PostmasterIsAlive
1        1.5e-04  postgres                 AtEOXact_LocalBuffers
1        1.5e-04  postgres                 AutoVacLauncherMain
1        1.5e-04  postgres                 BgWriterNap
1        1.5e-04  postgres                 ReleaseSysCache
1        1.5e-04  postgres                 backend_read_statsfile
1        1.5e-04  postgres                 heap_freetuple
1        1.5e-04  postgres                 smgrshutdown
/*
 * reconnect.c
 *
 *		Reconnect at top speed.
 */
#include <stdio.h>
#include <stdlib.h>
#include "libpq-fe.h"

static void
exit_nicely(PGconn *conn)
{
	PQfinish(conn);
	exit(1);
}

int
main(int argc, char **argv)
{
	const char *conninfo;
	PGconn	   *conn;

	/*
	 * If the user supplies a parameter on the command line, use it as the
	 * conninfo string; otherwise default to setting dbname=postgres and using
	 * environment variables or defaults for all other connection parameters.
	 */
	if (argc > 1)
		conninfo = argv[1];
	else
		conninfo = "dbname = postgres";

	/* Loop forever. */
	while (1)
	{
		/* Make a connection to the database */
		conn = PQconnectdb(conninfo);

		/* Check to see that the backend connection was successfully made */
		if (PQstatus(conn) != CONNECTION_OK)
		{
			fprintf(stderr, "Connection to database failed: %s",
					PQerrorMessage(conn));
			exit_nicely(conn);
		}

		/* close the connection to the database and cleanup */
		PQfinish(conn);
	}

	return 0;
}
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to