Thread: Out of memory for Select query.

Out of memory for Select query.

From
"Nimesh Satam"
Date:
All,
 
While running a Select query we get the below error:
 
ERROR:  out of memory
DETAIL:  Failed on request of size 192.
 
Postgres Conf details:
shared_buffers = 256000
work_mem =150000
max_stack_depth = 16384
max_fsm_pages = 400000
version: 8.1.3
 
We are using 8gb of Primary memory for the server which is used as a dedicated database machine.
 
The data log shows the below message after getting the Out of memory error. Also attached the explain for the query. Can someone let us know , if have some worng parameter setup or any solution to the problem?
 
Regards,
Nimesh.
 

TopMemoryContext: 57344 total in 6 blocks; 9504 free (12 chunks); 47840 used
TopTransactionContext: 8192 total in 1 blocks; 7856 free (0 chunks); 336 used
Type information cache: 8192 total in 1 blocks; 1864 free (0 chunks); 6328 used
Operator class cache: 8192 total in 1 blocks; 4936 free (0 chunks); 3256 used
MessageContext: 1040384 total in 7 blocks; 263096 free (4 chunks); 777288 used
JoinRelHashTable: 8192 total in 1 blocks; 3888 free (0 chunks); 4304 used
smgr relation table: 8192 total in 1 blocks; 1840 free (0 chunks); 6352 used
Portal hash: 8192 total in 1 blocks; 3912 free (0 chunks); 4280 used
PortalMemory: 8192 total in 1 blocks; 8040 free (0 chunks); 152 used
PortalHeapMemory: 1024 total in 1 blocks; 856 free (0 chunks); 168 used
ExecutorState: 122880 total in 4 blocks; 51840 free (6 chunks); 71040 used
HashTableContext: 0 total in 0 blocks; 0 free (0 chunks); 0 used
HashBatchContext: 2089044 total in 8 blocks; 573232 free (12 chunks); 1515812 used
HashTableContext: 0 total in 0 blocks; 0 free (0 chunks); 0 used
HashBatchContext: 2080768 total in 7 blocks; 749448 free (11 chunks); 1331320 used
HashTableContext: 0 total in 0 blocks; 0 free (0 chunks); 0 used
HashBatchContext: 245760 total in 4 blocks; 109112 free (4 chunks); 136648 used
HashTableContext: 0 total in 0 blocks; 0 free (0 chunks); 0 used
HashBatchContext: 1032192 total in 6 blocks; 504104 free (8 chunks); 528088 used
HashTableContext: 0 total in 0 blocks; 0 free (0 chunks); 0 used
HashBatchContext: 1032192 total in 6 blocks; 474456 free (8 chunks); 557736 used
HashTableContext: 0 total in 0 blocks; 0 free (0 chunks); 0 used
HashBatchContext: 2080768 total in 7 blocks; 783856 free (11 chunks); 1296912 used
ExprContext: 0 total in 0 blocks; 0 free (0 chunks); 0 used
ExprContext: 0 total in 0 blocks; 0 free (0 chunks); 0 used
.
.
.

AggContext: 941613056 total in 129 blocks; 13984 free (154 chunks); 941599072 used
TupleHashTable: 113303576 total in 24 blocks; 1347032 free (74 chunks); 111956544 used
ExprContext: 0 total in 0 blocks; 0 free (0 chunks); 0 used
ExprContext: 8192 total in 1 blocks; 8176 free (0 chunks); 16 used
Relcache by OID: 8192 total in 1 blocks; 3376 free (0 chunks); 4816 used
CacheMemoryContext: 516096 total in 6 blocks; 12080 free (0 chunks); 504016 used
rg_key_idx: 1024 total in 1 blocks; 392 free (0 chunks); 632 used
rg_idx: 1024 total in 1 blocks; 256 free (0 chunks); 768 used
rg_id_idx: 1024 total in 1 blocks; 392 free (0 chunks); 632 used
rc_key_idx: 1024 total in 1 blocks; 392 free (0 chunks); 632 used
r_c_idx: 1024 total in 1 blocks; 392 free (0 chunks); 632 used
r_c_id_idx: 1024 total in 1 blocks; 392 free (0 chunks); 632 used
r_ch_key_idx: 1024 total in 1 blocks; 392 free (0 chunks); 632 used
r_ch_id_idx: 1024 total in 1 blocks; 392 free (0 chunks); 632 used
r_ch_cd: 1024 total in 1 blocks; 392 free (0 chunks); 632 used
r_cm_key_idx: 1024 total in 1 blocks; 392 free (0 chunks); 632 used
r_c_m_id_idx: 1024 total in 1 blocks; 392 free (0 chunks); 632 used
r_s_key_idx: 1024 total in 1 blocks; 392 free (0 chunks); 632 used
r_p_id_idx: 1024 total in 1 blocks; 392 free (0 chunks); 632 used
r_p_cd_idx: 1024 total in 1 blocks; 392 free (0 chunks); 632 used
r_a_key_idx: 1024 total in 1 blocks; 392 free (0 chunks); 632 used
r_a_v_id_idx: 1024 total in 1 blocks; 392 free (0 chunks); 632 used
r_d_sqldt_idx: 1024 total in 1 blocks; 392 free (0 chunks); 632 used
r_da_key_idx: 1024 total in 1 blocks; 392 free (0 chunks); 632 used
r_nw_key_idx: 1024 total in 1 blocks; 392 free (0 chunks); 632 used
r_n_id_idx: 1024 total in 1 blocks; 392 free (0 chunks); 632 used
r_m_network_date_idx: 1024 total in 1 blocks; 328 free (0 chunks); 696 used
pg_index_indrelid_index: 1024 total in 1 blocks; 392 free (0 chunks); 632 used
pg_attrdef_adrelid_adnum_index: 1024 total in 1 blocks; 328 free (0 chunks); 696 used
pg_type_typname_nsp_index: 1024 total in 1 blocks; 328 free (0 chunks); 696 used
pg_type_oid_index: 1024 total in 1 blocks; 392 free (0 chunks); 632 used
pg_trigger_tgrelid_tgname_index: 1024 total in 1 blocks; 328 free (0 chunks); 696 used
pg_statistic_relid_att_index: 1024 total in 1 blocks; 328 free (0 chunks); 696 used
pg_auth_members_member_role_index: 1024 total in 1 blocks; 328 free (0 chunks); 696 used
pg_auth_members_role_member_index: 1024 total in 1 blocks; 328 free (0 chunks); 696 used
pg_rewrite_rel_rulename_index: 1024 total in 1 blocks; 328 free (0 chunks); 696 used
pg_proc_proname_args_nsp_index: 1024 total in 1 blocks; 256 free (0 chunks); 768 used
pg_proc_oid_index: 1024 total in 1 blocks; 392 free (0 chunks); 632 used
pg_operator_oprname_l_r_n_index: 1024 total in 1 blocks; 192 free (0 chunks); 832 used
pg_operator_oid_index: 1024 total in 1 blocks; 392 free (0 chunks); 632 used
pg_opclass_oid_index: 1024 total in 1 blocks; 392 free (0 chunks); 632 used
pg_opclass_am_name_nsp_index: 1024 total in 1 blocks; 256 free (0 chunks); 768 used
pg_namespace_oid_index: 1024 total in 1 blocks; 392 free (0 chunks); 632 used
pg_namespace_nspname_index: 1024 total in 1 blocks; 392 free (0 chunks); 632 used
pg_language_oid_index: 1024 total in 1 blocks; 392 free (0 chunks); 632 used
pg_language_name_index: 1024 total in 1 blocks; 392 free (0 chunks); 632 used
pg_inherits_relid_seqno_index: 1024 total in 1 blocks; 328 free (0 chunks); 696 used
pg_index_indexrelid_index: 1024 total in 1 blocks; 392 free (0 chunks); 632 used
pg_authid_oid_index: 1024 total in 1 blocks; 392 free (0 chunks); 632 used
pg_authid_rolname_index: 1024 total in 1 blocks; 392 free (0 chunks); 632 used
pg_database_datname_index: 1024 total in 1 blocks; 392 free (0 chunks); 632 used
pg_conversion_oid_index: 1024 total in 1 blocks; 392 free (0 chunks); 632 used
pg_conversion_name_nsp_index: 1024 total in 1 blocks; 328 free (0 chunks); 696 used
pg_conversion_default_index: 1024 total in 1 blocks; 192 free (0 chunks); 832 used
pg_class_relname_nsp_index: 1024 total in 1 blocks; 328 free (0 chunks); 696 used
pg_class_oid_index: 1024 total in 1 blocks; 392 free (0 chunks); 632 used
pg_cast_source_target_index: 1024 total in 1 blocks; 328 free (0 chunks); 696 used
pg_attribute_relid_attnum_index: 1024 total in 1 blocks; 328 free (0 chunks); 696 used
pg_attribute_relid_attnam_index: 1024 total in 1 blocks; 328 free (0 chunks); 696 used
pg_amproc_opc_proc_index: 1024 total in 1 blocks; 256 free (0 chunks); 768 used
pg_amop_opr_opc_index: 1024 total in 1 blocks; 328 free (0 chunks); 696 used
pg_amop_opc_strat_index: 1024 total in 1 blocks; 256 free (0 chunks); 768 used
pg_aggregate_fnoid_index: 1024 total in 1 blocks; 392 free (0 chunks); 632 used
MdSmgr: 8192 total in 1 blocks; 5584 free (0 chunks); 2608 used
LockTable (locallock hash): 8192 total in 1 blocks; 3912 free (0 chunks); 4280 used
Timezones: 47592 total in 2 blocks; 5968 free (0 chunks); 41624 used
ErrorContext: 8192 total in 1 blocks; 8176 free (0 chunks); 16 used
2008-06-29 20:48:25 PDT [13980]: [5-1] ERROR:  out of memory
2008-06-29 20:48:25 PDT [13980]: [6-1] DETAIL:  Failed on request of size 192.

 
 
 
 
 
Attachment

Re: Out of memory for Select query.

From
Rusty Conover
Date:

On Jun 29, 2008, at 10:20 PM, Nimesh Satam wrote:

> All,
>
> While running a Select query we get the below error:
>
> ERROR:  out of memory
> DETAIL:  Failed on request of size 192.
>
> Postgres Conf details:
> shared_buffers = 256000
> work_mem =150000
> max_stack_depth = 16384
> max_fsm_pages = 400000
> version: 8.1.3
>
> We are using 8gb of Primary memory for the server which is used as a
> dedicated database machine.
>
> The data log shows the below message after getting the Out of memory
> error. Also attached the explain for the query. Can someone let us
> know , if have some worng parameter setup or any solution to the
> problem?
>
> Regards,
> Nimesh.
>


Hi Nimesh,

I'd try decreasing work_mem (try something smaller like 16384 and work
up if you'd like), since you have lots of hashes being built for this
query, you may simply be running into a limit on process size
depending on your platform.  Also look at "ulimit -a" as the postgres
user to make sure you aren't running into any administrative limits.

Cheers,

Rusty
--
Rusty Conover
InfoGears Inc.
http://www.infogears.com