index question

From: "drum(dot)lucas(at)gmail(dot)com" <drum(dot)lucas(at)gmail(dot)com>
To: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: index question
Date: 2016-05-01 21:40:14
Message-ID: CAE_gQfWs2VDyfqAJwNhjHJrd=xUnuCqrErYZtLGHUqjmLB_Trg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all,

I've got the following index on the gorfs.inode_segments table:

>
> CREATE INDEX ix_clientids
> ON gorfs.inode_segments
> USING btree
> (("split_part"("full_path"::"text", '/'::"text", 4)::integer))
> WHERE "gorfs"."is_kaminski_note_path"("full_path"::"text");

And I'm running the following Query:

> SELECT
> * FROM ( SELECT split_part(full_path, '/', 4)::INT AS account_id,
> split_part(full_path, '/', 6)::INT AS note_id,
> split_part(full_path, '/', 9)::TEXT AS variation,
> st_size,
> segment_index,
> reverse(split_part(reverse(full_path), '/', 1)) as file_name,
> i.st_ino,
> full_path
> FROM gorfs.inodes i
> JOIN gorfs.inode_segments s
> ON i.st_ino = s.st_ino_target
> WHERE i.checksum_md5 IS NOT NULL
> AND s.full_path ~ '/userfiles/account/[0-9]+/[a-z]+/[0-9]+'
> AND i.st_size > 0) as test WHERE account_id = 12225

*- But the query does not use the index... Why?*

Explain analyze:

> "Seq Scan on "inode_segments" (cost=0.00..3047212.44 rows=524846
> width=63) (actual time=14212.466..51428.439 rows=31 loops=1)"
> " Filter: ("split_part"(("full_path")::"text", '/'::"text", 4) =
> '12225'::"text")"
> " Rows Removed by Filter: 104361402"
> "Total runtime: 51428.482 ms"

Cheers
Lucas

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Melvin Davidson 2016-05-01 21:52:45 Re: index question
Previous Message Tom Smith 2016-05-01 20:22:38 Re: JSONB performance enhancement for 9.6