Note that there are some explanatory texts on larger screens.

plurals
  1. POsql Like alternate
    primarykey
    data
    text
    <p>Is there any other solution available to use instead of Like to match starts with?</p> <p>here is my query to match starts with using like.</p> <pre><code>explain analyze select * from completedcalls where call_id like 'GWYA4NvSLzoIcvA7RAtmn_a9IelwOQeH@209.44.103.3%'; QUERY PLAN ------------------------------------------------------------------------------------------------------------------ Seq Scan on completedcalls (cost=0.00..52659.96 rows=112 width=228) (actual time=1.541..249.857 rows=2 loops=1) Filter: ((call_id)::text ~~ 'GWYA4NvSLzoIcvA7RAtmn_a9IelwOQeH@209.44.103.3%'::text) Total runtime: 249.893 ms (3 rows) </code></pre> <p>which is very expansive because it does sequence scan instead of index scan. due to nature of like it can not use index on provided column. index of column is simple as:</p> <pre><code>"i_call_id" btree (call_id) </code></pre> <p>Is there any special class of index which can help like to improve speed, or any other way to achieve same without using like?</p> <p>Used Table script is:</p> <pre><code> Table "public.completedcalls" Column | Type | Modifiers ---------------+--------------------------+-------------- call_id | character varying(128) | sip_code | integer | duration | integer | setup_time | timestamp with time zone | not null authname | character varying(30) | src_sig_ip | character varying(20) | dst_sig_ip | character varying(20) | cld | character varying(22) | cli | character varying(22) | Indexes: "i_call_id" btree (call_id) "i_dst_sig_ip" btree (dst_sig_ip) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload