- Code: Select all
EXPLAIN ANALYSE SELECT COALESCE(to_char(document_number,'99999999'),'n/a') || ' ' || to_char(document_date,'dd/MM/YY') || ' ' || COALESCE(document_customer_acc_no,'') || ' ' || COALESCE(document_customer_name,''), document_id FROM acc_documents WHERE
document_number = 1210001 OR document_customer_acc_no = '1210001' ORDER BY document_date DESC OFFSET 0 LIMIT 26
"Limit (cost=119.99..120.06 rows=26 width=41) (actual time=0.063..0.064 rows=1 loops=1)"
" -> Sort (cost=119.99..120.06 rows=28 width=41) (actual time=0.062..0.062 rows=1 loops=1)"
" Sort Key: document_date"
" Sort Method: quicksort Memory: 25kB"
" -> Bitmap Heap Scan on acc_documents (cost=8.82..119.32 rows=28 width=41) (actual time=0.056..0.056 rows=1 loops=1)"
" Recheck Cond: ((document_number = 1210001) OR ((document_customer_acc_no)::text = '1210001'::text))"
" -> BitmapOr (cost=8.82..8.82 rows=28 width=0) (actual time=0.037..0.037 rows=0 loops=1)"
" -> Bitmap Index Scan on acc_documents2_document_number_ndx (cost=0.00..4.33 rows=1 width=0) (actual time=0.012..0.012 rows=1 loops=1)"
" Index Cond: (document_number = 1210001)"
" -> Bitmap Index Scan on document_customer_account_number_ndx (cost=0.00..4.48 rows=27 width=0) (actual time=0.024..0.024 rows=0 loops=1)"
" Index Cond: ((document_customer_acc_no)::text = '1210001'::text)"
"Total runtime: 0.091 ms"
Without the Explain Analyse it runs in 17ms.