Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id EE0647661B9 for ; Thu, 21 Jun 2012 17:07:17 -0300 (ADT) Received: from blu0-omc4-s14.blu0.hotmail.com ([65.55.111.153]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Shnet-0002ZN-6X for pgsql-performance@postgresql.org; Thu, 21 Jun 2012 20:07:17 +0000 Received: from BLU123-W20 ([65.55.111.135]) by blu0-omc4-s14.blu0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 21 Jun 2012 13:07:02 -0700 Message-ID: Content-Type: multipart/alternative; boundary="_39845234-4cfc-4dec-9743-5c5e89ec0ac2_" X-Originating-IP: [81.96.108.153] From: Andy Halsall To: Subject: Can I do better than this heapscan and sort? Date: Thu, 21 Jun 2012 20:07:01 +0000 Importance: Normal MIME-Version: 1.0 X-OriginalArrivalTime: 21 Jun 2012 20:07:02.0161 (UTC) FILETIME=[6C014810:01CD4FE9] X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201206/128 X-Sequence-Number: 47154 --_39845234-4cfc-4dec-9743-5c5e89ec0ac2_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I have two tables node and relationship. Each relationship record connects = two nodes and has an application keys (unfortunately named) that can be use= d by the application to look-up a relationship and get from one node to the= other. =20 My query uses a node id and a description of a relationship from the node= =2C and must find the "next" relationship that the node has. It does this b= y finding all the relationships that could be "next"=2C ordering them and t= hen getting the first.=20 =20 Details are below but I end up with 6896 candidates for "next". =20 =20 If I'm reading the output correctly it takes 13.509 ms to apply the filter = and another 7 ms or so to do the sort of the remaining 6896 nodes. =20 Have tried many index combinations to try and improve the results. I suspec= t that with so many nodes to sort=2C postgresql will opt for heap scan rath= er than index. But why does it not use the IDX_order_sort_down_2 index for = the sort? =20 Thanks=2C Andy =20 =20 Details.......... =20 Version ------- PostgreSQL 9.1.2 on x86_64-unknown-linux-gnu=2C compiled by gcc (GCC) 4.5.2= =2C 64-bit Tables ------ CREATE TABLE node (=20 node_id bigint NOT NULL=2C node_type int4 NOT NULL=2C c_state int4 NOT NULL=2C d_state int4 NOT NULL=2C sort_key bigint NOT NULL=2C permissions bytea NOT NULL=2C audit bytea NOT NULL=2C pkg_id bytea NULL=2C created timestamp NOT NULL )=3B CREATE TABLE relationship (=20 rel_id bigint NOT NULL=2C rel_type integer NOT NULL=2C s_t_n bigint NOT NULL=2C t_s_n bigint NOT NULL=2C state integer NOT NULL=2C control integer NOT NULL=2C sort_key bigint NOT NULL=2C prime_key bytea NULL=2C prime_key_len integer NOT NULL=2C sec_key bytea NULL=2C sec_key_len integer NOT NULL=2C up_sort_key bigint NOT NULL=2C up_prime_key bytea NULL=2C up_prime_key_len integer NOT NULL=2C up_sec_key bytea NULL=2C up_sec_key_len integer NOT NULL=2C permissions bytea NOT NULL=2C t_s_n_type integer NOT NULL=2C created timestamp NOT NULL )=3B Constraints ----------- -- Primary keys=20 ALTER TABLE node ADD CONSTRAINT PK_node PRIMARY KEY (node_id)=3B =20 ALTER TABLE relationship ADD CONSTRAINT PK_relationship PRIMARY KEY (rel_id= )=3B =20 -- Foreign keys ALTER TABLE relationship ADD CONSTRAINT FK_node_s FOREIGN KEY (s_t_n) REFER= ENCES node (node_id)=3B =20 ALTER TABLE relationship ADD CONSTRAINT FK_node_n FOREIGN KEY (t_s_n) REFER= ENCES node (node_id)=3B =20 Indexes=20 ------- CREATE INDEX IDX_node_type ON node (node_type ASC) TABLESPACE ds_appex_ts_1= 0 =3B CREATE INDEX IDX_node_sort_key ON node (sort_key ASC) TABLESPACE ds_appex_t= s_10 =3B CREATE INDEX IDX_relationship_s_t_n ON relationship (s_t_n ASC) TABLESPACE = ds_appex_ts_10=20 =3B CREATE INDEX IDX_relationship_t_s_n ON relationship (t_s_n ASC) TABLESPACE = ds_appex_ts_10=20 =3B CREATE INDEX IDX_relationship_type ON relationship (rel_type ASC) TABLESPAC= E ds_appex_ts_10=20 =3B CREATE INDEX IDX_relationship_prime_key ON relationship (prime_key ASC) TAB= LESPACE ds_appex_ts_10=20 =3B CREATE INDEX IDX_relationship_u_prime_key ON relationship (up_prime_key ASC= ) TABLESPACE ds_appex_ts_10=20 =3B CREATE INDEX IDX_relationship_sec_key ON relationship (sec_key ASC) TABLESP= ACE ds_appex_ts_10=20 =3B CREATE INDEX IDX_order_first ON node(sort_key DESC=2C node_id DESC) TABLESP= ACE ds_appex_ts_10 =3B CREATE INDEX IDX_order_sort_down_1 ON relationship(sort_key DESC=2C prime_k= ey ASC NULLS FIRST=2C sec_key ASC NULLS FIRST) TABLESPACE ds_appex_ts_10 =3B CREATE INDEX IDX_order_sort_down_2 ON relationship(sort_key DESC=2C prime_k= ey ASC NULLS FIRST=2C sec_key DESC NULLS FIRST) TABLESPACE ds_appex_ts_10 =3B CREATE INDEX IDX_order_sort_up ON relationship(up_sort_key DESC=2C up_prime= _key ASC NULLS FIRST=2C up_sec_key ASC NULLS FIRST) TABLESPACE ds_appex_ts_= 10 =3B =20 Query ----- CREATE OR REPLACE FUNCTION sp_get_rel_sort_dup_sec_desc(in_rel_type1 intege= r=2C in_rel_type2 integer=2C in_node_type integer=2C in_own_guid bigint=2C = in_prev_prime_key bytea=2C in_prev_prime_key_len integer=2C in_prev_sec_key= bytea=2C in_prev_sec_key_len integer=2C in_prev_sort_key bigint=2C in_ctrl= integer) RETURNS select_rel_holder AS ' declare h select_rel_holder%rowtype=3B =20 begin SELECT INTO h r.rel_id=2C r.t_s_n=2C r.rel_type=2C r.sort_key=2C r.state=2Cr.permissions=2C r.control=2C=20 r.prime_key=2C r.prime_key_len=2C r.sec_key=2C r.sec_= key_len=2C=20 r.up_prime_key=2C r.up_prime_key_len=2C r.up_sec_key= =2C r.up_sec_key_len FROM relationship r=20 WHERE r.s_t_n =3D in_own_guid AND (r.rel_type =3D in_rel_type1 OR r= .rel_type =3D in_rel_type2)=20 AND ( (=20 ( r.prime_key > in_prev_prime_key OR ( r.prime_key =3D in_prev_prime_key AND r.sec_key < in_pr= ev_sec_key) ) AND r.sort_key =3D in_prev_sort_key ) =20 OR r.sort_key < in_prev_sort_key ) AND t_s_n_type =3D in_node_type AND r.control >=3D in_ctrl ORDER BY sort_key DESC=2C prime_key ASC NULLS FIRST=2C sec_key DESC= NULLS FIRST LIMIT 1=3B RETURN h=3B end ' language 'plpgsql' STABLE=3B =20 =20 EXPLAIN ANALYZE output ------------------------------- Limit (cost=3D48.90..48.90 rows=3D1 width=3D89) (actual time=3D21.= 480..21.480 rows=3D1 loops=3D1) Output: rel_id=2C t_s_n=2C rel_type=2C sort_key=2C state=2C permi= ssions=2C control=2C prime_key=2C prime_key_len=2C sec_key=2C sec_key_len= =2C up_prime_key=2C up_prime_key_l en=2C up_sec_key=2C up_sec_key_len =20 -> Sort (cost=3D48.90..48.90 rows=3D1 width=3D89) (actual time= =3D21.479..21.479 rows=3D1 loops=3D1) Output: rel_id=2C t_s_n=2C rel_type=2C sort_key=2C state=2C= permissions=2C control=2C prime_key=2C prime_key_len=2C sec_key=2C sec_key= _len=2C up_prime_key=2C up_prime _key_len=2C up_sec_key=2C up_sec_key_len Sort Key: r.sort_key=2C r.prime_key=2C r.sec_key Sort Method: top-N heapsort Memory: 25kB =20 -> Bitmap Heap Scan on public.relationship r (cost=3D3.39= ..48.89 rows=3D1 width=3D89) (actual time=3D1.034..13.509 rows=3D6986 loops= =3D1) Output: rel_id=2C t_s_n=2C rel_type=2C sort_key=2C st= ate=2C permissions=2C control=2C prime_key=2C prime_key_len=2C sec_key=2C s= ec_key_len=2C up_prime_key=2C up _prime_key_len=2C up_sec_key=2C up_sec_key_len Recheck Cond: (r.s_t_n =3D $4) Filter: ((r.control >=3D $10) AND (r.t_s_n_type =3D $= 3) AND ((r.rel_type =3D $1) OR (r.rel_type =3D $2)) AND ((((r.prime_key > $= 5) OR ((r.prime_ key =3D $5) AND (r.sec_key < $7))) AND (r.sort_key =3D $9)) OR (r.sort_key = < $9))) =20 -> Bitmap Index Scan on idx_relationship_s_t_n (cos= t=3D0.00..3.39 rows=3D18 width=3D0) (actual time=3D0.951..0.951 rows=3D6989= loops=3D1) Index Cond: (r.s_t_n =3D $4) = --_39845234-4cfc-4dec-9743-5c5e89ec0ac2_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
I have two tables node and relationship. Each relationship record connects = two nodes and has an application keys (unfortunately named) that can be use= d by the application to look-up a relationship and get from one node to the= other.
 =3B
My query uses a node id and a description of a relationship from the node= =2C and must find the "next" relationship that the node has. =3BIt does= this by finding all the relationships that could be "next"=2C =3Border= ing them and then getting the first. =3B
 =3B
Details are below but I end up with 6896 candidates for "next". =3B  =3B
If I'm reading the output correctly it takes 13.509 ms to apply the filter = and another 7 ms or so to do the sort of the remaining 6896 nodes.
 =3B
Have tried many index combinations to try and improve the results. =3BI= suspect that with so many nodes to sort=2C postgresql will opt for heap sc= an rather than index. But why does it not use the IDX_order_sort_down_2 ind= ex for the sort?
 =3B
Thanks=2C
Andy
 =3B
 =3B
Details..........
 =3B
Version
-------
PostgreSQL 9.1.2 on x86_64-unknown-linux-gnu=2C compi= led by gcc (GCC) 4.5.2=2C 64-bit

Tables
------
CREATE TABLE node (
 =3Bnode_id =3B =3B =3B =3B&nbs= p=3B bigint NOT NULL=2C
 =3Bnode_type =3B =3B =3B int4 N= OT NULL=2C
 =3Bc_state =3B =3B =3B =3B =3B int4 = NOT NULL=2C
 =3Bd_state =3B =3B =3B =3B =3B int4= NOT NULL=2C
 =3Bsort_key =3B =3B =3B =3B bigint NOT= NULL=2C
 =3Bpermissions =3B bytea NOT NULL=2C
 =3Baudit&= nbsp=3B =3B =3B =3B =3B =3B =3B bytea =3B NOT N= ULL=2C
 =3Bpkg_id =3B =3B =3B =3B =3B =3B by= tea NULL=2C
 =3Bcreated =3B =3B =3B =3B =3B time= stamp NOT NULL
)=3B

CREATE TABLE relationship (
 =3Brel_id =3B =3B =3B&= nbsp=3B =3B =3B =3B =3B =3B =3B bigint NOT NULL=2C<= BR> =3Brel_type =3B =3B =3B =3B =3B =3B =3B=  =3B integer NOT NULL=2C
 =3Bs_t_n =3B =3B =3B = =3B =3B =3B =3B =3B =3B =3B =3B bigint NOT NULL= =2C
 =3Bt_s_n =3B =3B =3B =3B =3B =3B = =3B =3B =3B =3B =3B bigint NOT NULL=2C
 =3Bstate&nbs= p=3B =3B =3B =3B =3B =3B =3B =3B =3B = =3B =3B integer NOT NULL=2C
 =3Bcontrol =3B =3B =3B&= nbsp=3B =3B =3B =3B =3B =3B integer NOT NULL=2C
&nbs= p=3Bsort_key =3B =3B =3B =3B =3B =3B =3B = =3B bigint NOT NULL=2C
 =3Bprime_key =3B =3B =3B =3B=  =3B =3B =3B bytea NULL=2C
 =3Bprime_key_len =3B&nbs= p=3B =3B integer NOT NULL=2C
 =3Bsec_key =3B =3B =3B=  =3B =3B =3B =3B =3B =3B bytea NULL=2C
 =3Bs= ec_key_len =3B =3B =3B =3B =3B integer NOT NULL=2C
&= nbsp=3Bup_sort_key =3B =3B =3B =3B =3B bigint NOT NULL= =2C
 =3Bup_prime_key =3B =3B =3B =3B bytea NULL=2C =3Bup_prime_key_len integer NOT NULL=2C
 =3Bup_sec_key = =3B =3B =3B =3B =3B =3B bytea NULL=2C
 =3Bup_sec= _key_len =3B =3B integer NOT NULL=2C
 =3Bpermissions =3B=  =3B =3B =3B =3B bytea NOT NULL=2C
 =3Bt_s_n_type&nb= sp=3B =3B =3B =3B =3B =3B integer NOT NULL=2C
 = =3Bcreated =3B =3B =3B =3B =3B =3B =3B =3B&= nbsp=3B timestamp NOT NULL
)=3B

Constraints
-----------
-- Primary keys
ALTER TABLE node ADD CONSTRAINT PK_node =3BPRIMARY = KEY (node_id)=3B
 =3B =3B
ALTER TABLE relationship ADD CONSTR= AINT PK_relationship =3BPRIMARY KEY (rel_id)=3B
 =3B
-- Foreign keys
ALTER TABLE relationship ADD CONSTRAINT FK_node_s = =3BFOREIGN KEY (s_t_n) REFERENCES node (node_id)=3B
 =3B
ALTER TABLE relationship ADD CONSTRAINT FK_node_n =3BFOREIGN KEY (t_s_n= ) REFERENCES node (node_id)=3B

 =3B
Indexes
-------
CREATE INDEX IDX_node_type ON node = (node_type ASC) TABLESPACE ds_appex_ts_10
=3B
CREATE INDEX IDX_node_s= ort_key ON node (sort_key ASC) TABLESPACE ds_appex_ts_10
=3B
CREATE I= NDEX IDX_relationship_s_t_n ON relationship (s_t_n ASC) TABLESPACE ds_appex= _ts_10
=3B
CREATE INDEX IDX_relationship_t_s_n ON relationship (t_s_= n ASC) TABLESPACE ds_appex_ts_10
=3B
CREATE INDEX IDX_relationship_t= ype ON relationship (rel_type ASC) TABLESPACE ds_appex_ts_10
=3B
CRE= ATE INDEX IDX_relationship_prime_key ON relationship (prime_key ASC) TABLES= PACE ds_appex_ts_10
=3B
CREATE INDEX IDX_relationship_u_prime_key ON= relationship (up_prime_key ASC) TABLESPACE ds_appex_ts_10
=3B
CREAT= E INDEX IDX_relationship_sec_key ON relationship (sec_key ASC) TABLESPACE d= s_appex_ts_10
=3B
CREATE INDEX IDX_order_first ON node(sort_key DESC= =2C node_id DESC) TABLESPACE ds_appex_ts_10
=3B
CREATE INDEX IDX_orde= r_sort_down_1 ON relationship(sort_key DESC=2C prime_key ASC NULLS FIRST=2C= sec_key ASC NULLS FIRST) TABLESPACE ds_appex_ts_10
=3B
CREATE INDEX = IDX_order_sort_down_2 ON relationship(sort_key DESC=2C prime_key ASC NULLS = FIRST=2C sec_key DESC NULLS FIRST) TABLESPACE ds_appex_ts_10
=3B
CREA= TE INDEX IDX_order_sort_up ON relationship(up_sort_key DESC=2C up_prime_key= ASC NULLS FIRST=2C up_sec_key ASC NULLS FIRST) TABLESPACE ds_appex_ts_10=3B
 =3B
Query
-----
CREATE OR REPLACE FUNCTION sp_get_rel_sort_dup_sec_desc(i= n_rel_type1 integer=2C in_rel_type2 integer=2C in_node_type integer=2C in_o= wn_guid bigint=2C in_prev_prime_key bytea=2C in_prev_prime_key_len integer= =2C in_prev_sec_key bytea=2C in_prev_sec_key_len integer=2C in_prev_sort_ke= y bigint=2C in_ctrl integer) RETURNS select_rel_holder AS
'
declareh select_rel_holder%rowtype=3B
 =3B
begin
 =3B =3B&= nbsp=3B =3B =3B =3B SELECT INTO h =3B r.rel_id=2C r.t_s_n= =2C r.rel_type=2C r.sort_key=2C
 =3B =3B =3B =3B =3B=  =3B =3B =3B =3B =3B =3B =3B =3B =3B&nb= sp=3B =3B =3B =3B =3B =3B =3B r.state=2Cr.permissio= ns=2C r.control=2C
 =3B =3B =3B =3B =3B =3B&nbs= p=3B =3B =3B =3B =3B =3B =3B =3B =3B = =3B =3B =3B =3B =3B =3B r.prime_key=2C r.prime_key_len= =2C r.sec_key=2C r.sec_key_len=2C
 =3B =3B =3B =3B = =3B =3B =3B =3B =3B =3B =3B =3B =3B =3B=  =3B =3B =3B =3B =3B =3B =3B r.up_prime_key=2C = r.up_prime_key_len=2C r.up_sec_key=2C r.up_sec_key_len
 =3B =3B&= nbsp=3B =3B =3B =3B =3B FROM relationship r
 =3B&nb= sp=3B =3B =3B =3B =3B =3B WHERE r.s_t_n =3D in_own_guid= AND (r.rel_type =3D in_rel_type1 OR r.rel_type =3D in_rel_type2)
 = =3B =3B =3B =3B =3B =3B =3B AND
 =3B =3B=  =3B =3B =3B =3B =3B (
 =3B =3B =3B = =3B =3B =3B =3B =3B =3B =3B =3B (
 =3B&= nbsp=3B =3B =3B =3B =3B =3B =3B =3B =3B&nbs= p=3B =3B =3B =3B (
 =3B =3B =3B =3B =3B&= nbsp=3B =3B =3B =3B =3B =3B =3B =3B =3B&nbs= p=3B =3B =3B r.prime_key >=3B in_prev_prime_key
 =3B = =3B =3B =3B =3B =3B =3B =3B =3B =3B =3B=  =3B =3B =3B =3B =3B =3B OR
 =3B =3B&nbs= p=3B =3B =3B =3B =3B =3B =3B =3B =3B = =3B =3B =3B =3B =3B =3B ( r.prime_key =3D in_prev_prime= _key AND r.sec_key <=3B in_prev_sec_key)
 =3B =3B =3B = =3B =3B =3B =3B =3B =3B =3B =3B =3B =3B=  =3B )
 =3B =3B =3B =3B =3B =3B =3B = =3B =3B =3B =3B =3B =3B =3B AND
 =3B =3B=  =3B =3B =3B =3B =3B =3B =3B =3B =3B&nb= sp=3B =3B =3B r.sort_key =3D in_prev_sort_key
 =3B =3B&n= bsp=3B =3B =3B =3B =3B =3B =3B =3B =3B ) =3B =3B =3B =3B =3B =3B =3B =3B
 = =3B =3B =3B =3B =3B =3B =3B =3B =3B =3B=  =3B OR
 =3B =3B =3B =3B =3B =3B =3B&nbs= p=3B =3B =3B =3B r.sort_key <=3B in_prev_sort_key
 =3B=  =3B =3B =3B =3B =3B =3B )
 =3B =3B = =3B =3B =3B =3B =3B AND t_s_n_type =3D in_node_type
&nbs= p=3B =3B =3B =3B =3B =3B =3B AND r.control >=3B= =3D in_ctrl
 =3B =3B =3B =3B =3B =3B =3B ORDER BY sort_key = DESC=2C prime_key ASC NULLS FIRST=2C sec_key DESC NULLS FIRST LIMIT 1=3B =3B =3B =3B =3B =3B =3B =3B RETURN h=3B
en= d
'
language 'plpgsql' STABLE=3B
 =3B
 =3B
EXPLAIN ANALYZE output
-------------------------------
 =3B = =3B =3B =3B =3B =3B =3B Limit =3B (cost=3D48.90..48= .90 rows=3D1 width=3D89) (actual time=3D21.480..21.480 rows=3D1 loops=3D1)<= BR> =3B =3B =3B =3B =3B =3B =3B =3B =3B= Output: rel_id=2C t_s_n=2C rel_type=2C sort_key=2C state=2C permissions=2C= control=2C prime_key=2C prime_key_len=2C sec_key=2C sec_key_len=2C up_prim= e_key=2C up_prime_key_l
en=2C up_sec_key=2C up_sec_key_len
 =3B
 =3B =3B =3B =3B =3B =3B =3B =3B =3B -&= gt=3B =3B Sort =3B (cost=3D48.90..48.90 rows=3D1 width=3D89) (actua= l time=3D21.479..21.479 rows=3D1 loops=3D1)
 =3B =3B =3B&nbs= p=3B =3B =3B =3B =3B =3B =3B =3B =3B = =3B =3B =3B Output: rel_id=2C t_s_n=2C rel_type=2C sort_key=2C stat= e=2C permissions=2C control=2C prime_key=2C prime_key_len=2C sec_key=2C sec= _key_len=2C up_prime_key=2C up_prime
_key_len=2C up_sec_key=2C up_sec_ke= y_len
 =3B =3B =3B =3B =3B =3B =3B =3B&n= bsp=3B =3B =3B =3B =3B =3B =3B Sort Key: r.sort_key= =2C r.prime_key=2C r.sec_key
 =3B =3B =3B =3B =3B&nb= sp=3B =3B =3B =3B =3B =3B =3B =3B =3B = =3B Sort Method: top-N heapsort =3B Memory: 25kB
 =3B
 =3B =3B =3B =3B =3B =3B =3B =3B =3B&nb= sp=3B =3B =3B =3B =3B =3B ->=3B =3B Bitmap Heap S= can on public.relationship r =3B (cost=3D3.39..48.89 rows=3D1 width=3D8= 9) (actual time=3D1.034..13.509 rows=3D6986 loops=3D1)
 =3B =3B&= nbsp=3B =3B =3B =3B =3B =3B =3B =3B =3B&nbs= p=3B =3B =3B =3B =3B =3B =3B =3B =3B = =3B Output: rel_id=2C t_s_n=2C rel_type=2C sort_key=2C state=2C permissions= =2C control=2C prime_key=2C prime_key_len=2C sec_key=2C sec_key_len=2C up_p= rime_key=2C up
_prime_key_len=2C up_sec_key=2C up_sec_key_len
 = =3B =3B =3B =3B =3B =3B =3B =3B =3B =3B=  =3B =3B =3B =3B =3B =3B =3B =3B =3B&nb= sp=3B =3B Recheck Cond: (r.s_t_n =3D $4)
 =3B =3B =3B&nb= sp=3B =3B =3B =3B =3B =3B =3B =3B =3B = =3B =3B =3B =3B =3B =3B =3B =3B =3B Filter:= ((r.control >=3B=3D $10) AND (r.t_s_n_type =3D $3) AND ((r.rel_type =3D = $1) OR (r.rel_type =3D $2)) AND ((((r.prime_key >=3B $5) OR ((r.prime_key =3D $5) AND (r.sec_key <=3B $7))) AND (r.sort_key =3D $9)) OR (r.sor= t_key <=3B $9)))
 =3B
 =3B =3B =3B =3B =3B =3B =3B =3B =3B&nb= sp=3B =3B =3B =3B =3B =3B =3B =3B =3B = =3B =3B =3B ->=3B =3B Bitmap Index Scan on idx_relationship_s= _t_n =3B (cost=3D0.00..3.39 rows=3D18 width=3D0) (actual time=3D0.951..= 0.951 rows=3D6989 loops=3D1)
 =3B =3B =3B =3B =3B&nb= sp=3B =3B =3B =3B =3B =3B =3B =3B =3B = =3B =3B =3B =3B =3B =3B =3B =3B =3B =3B=  =3B =3B =3B Index Cond: (r.s_t_n =3D $4)
 =3B
= --_39845234-4cfc-4dec-9743-5c5e89ec0ac2_--