Why my query not doing index only scan

2018-09-10 Thread Arup Rakshit
1226 width=0) (actual time=0.347..0.347 rows=1232 loops=1) Index Cond: (company_id = '7881ff2e-0557-4734-9da8-2d33072ff1ef'::uuid) Planning time: 0.207 ms Execution time: 1.358 ms (7 rows) Thanks, Arup Rakshit a...@zeit.io

Re: Why my query not doing index only scan

2018-09-10 Thread Arup Rakshit
rows=1232 loops=1) Index Cond: (company_id = '7881ff2e-0557-4734-9da8-2d33072ff1ef'::uuid) Heap Fetches: 0 Planning time: 0.190 ms Execution time: 0.778 ms (5 rows) Thanks, Arup Rakshit a...@zeit.io > On 10-Sep-2018, at 4:58 PM, Stephen Frost wrote: > > VACUUM

Re: Why my query not doing index only scan

2018-09-10 Thread Arup Rakshit
Hello Stephen, I would like to ask one more question related to this topic. When I take a dump from production, and restore it to development DB, what are the commands I generally need to run to dev deb quack close to production? Thanks, Arup Rakshit a...@zeit.io > On 10-Sep-2018, at 4

Why order by column not using index with distinct keyword in select clause?

2018-09-11 Thread Arup Rakshit
) Planning time: 0.213 ms Execution time: 9.086 ms (3 rows) aruprakshit=# Thanks, Arup Rakshit a...@zeit.io

help to query json column

2018-03-06 Thread Arup Rakshit
Hi, I would like to select only rows where signature has a non null value. My json looks like : { "carInspection": { "damages": [ { "x": 68.670309653916, "y": 44.08014571949, "errors": [ { "code": "BR", "description":

Re: help to query json column

2018-03-07 Thread Arup Rakshit
Thanks Charles. that worked. > On Mar 7, 2018, at 12:27 PM, Charles Clavadetscher > <clavadetsc...@swisspug.org> wrote: > > Hello > >> -Original Message- >> From: Arup Rakshit [mailto:aruprakshit1...@outlook.com] >> Sent: Mittwoch,

Re: Why my query not using index to sort?

2018-09-30 Thread Arup Rakshit
'36825da8-2f58-4a62-bdb4-2b91cbe18299', 'cca256cf-b415-472c-8b9f-a8432d02c580'); Time: 14.377 ms docking_dev=# Thanks, Arup Rakshit a...@zeit.io > On 29-Sep-2018, at 2:50 AM, Adrian

How to improve sql query to achieve the better plan

2018-09-30 Thread Arup Rakshit
; btree (parent_workitem_id) "index_workitems_on_project_id" btree (project_id) "index_workitems_on_standard_workitem_id" btree (standard_workitem_id) "index_workitems_on_workitem_category_id" btree (workitem_category_id) Thanks, Arup Rakshit a...@zeit.io

Re: How to improve sql query to achieve the better plan

2018-09-30 Thread Arup Rakshit
; btree (project_id) "index_workitems_on_standard_workitem_id" btree (standard_workitem_id) "index_workitems_on_workitem_category_id" btree (workitem_category_id) "patrial_index_workitems_200_1" btree (project_id) WHERE deleted_at IS NULL Thanks, Arup

ERROR: type "myrowtype" does not exist

2018-10-26 Thread Arup Rakshit
t;: "a b c"}}'); ERROR: type "myrowtype" does not exist LINE 1: select * from json_populate_record(null::myrowtype, '{"a": 1… What does null::extype, null::myrowtype mean here ? Thanks, Arup Rakshit a...@zeit.io

Re: Why my query not using index to sort?

2018-09-29 Thread Arup Rakshit
Hello Adrian, I used to consider this time as the sql execution time approximately. I’ll do some research and get back to you. Thanks for mentioning it. Thanks, Arup Rakshit a...@zeit.io > On 29-Sep-2018, at 2:50 AM, Adrian Klaver wrote: > > On 9/28/18 12:14 PM, Arup Raks

Re: Help to understand Actual Rows vs Plan Rows from the query planner output

2018-09-28 Thread Arup Rakshit
ires some experience to master, but this section attempts to cover the basics..” Lets see how can I get there. :) I probably need to ask a lot of questions. Thanks for sharing those points. I made a note about them. Thanks, Arup Rakshit a...@zeit.io > On 25-Sep-2018, at 11:45 AM, Laurenz

Re: Why my query not using index to sort?

2018-09-28 Thread Arup Rakshit
4ad6 <https://gist.github.com/aruprakshit/a6bd7ca221c9a13cd583e0827aa24ad6> Thanks, Arup Rakshit a...@zeit.io > On 29-Sep-2018, at 12:28 AM, Adrian Klaver wrote: > > On 9/28/18 11:51 AM, Arup Rakshit wrote: >> Yes, I have shown the explain plan output. But in my applica

Re: Why my query not using index to sort?

2018-09-28 Thread Arup Rakshit
Yes. But I thought I could improve it, so that it can be finished in 0.xx ms. It takes now between 1.7 to 1.9 ms in production. Thanks, Arup Rakshit a...@zeit.io > On 28-Sep-2018, at 9:46 PM, Andreas Kretschmer > wrote: > > > > Am 28.09.2018 um 18:03 schrieb Arup

Re: Why my query not using index to sort?

2018-09-28 Thread Arup Rakshit
Yes, I have shown the explain plan output. But in my application log the sql query prints 1.7 to 1.9 ms. Thanks, Arup Rakshit a...@zeit.io > On 29-Sep-2018, at 12:17 AM, Adrian Klaver wrote: > > On 9/28/18 11:32 AM, Arup Rakshit wrote: >> Yes. But I thought I could

Re: Why my query not using index to sort?

2018-09-28 Thread Arup Rakshit
Forgot to mention in my previous email, it was a quick send click. Sorry for that. In the gist you need to see all the line with Vessel Load(.. . I load the page multiple times to catch the different times, so you will the line multiple times there in the log file. Thanks, Arup Rakshit

Re: Why my query not using index to sort?

2018-09-29 Thread Arup Rakshit
(item_code) "index_standard_workitems_on_workitem_category_id" btree (workitem_category_id) "standard_workitems_partial_index_idx_1_1" btree (company_id, item_code) WHERE deleted_at IS NULL Thanks, Arup Rakshit a...@zeit.io > On 28-Sep-2018, at 7:07 PM, Tom Lane

Re: Why my query not using index to sort?

2018-09-29 Thread Arup Rakshit
-fdd7-4efb-a163-c2b42e6486ae'::uuid) Planning time: 0.191 ms Execution time: 1.210 ms I have no idea why PG thinks in memory sort will be cheaper.. Thanks, Arup Rakshit a...@zeit.io > On 29-Sep-2018, at 9:40 PM, Arup Rakshit wrote: > > Hello Tom, > > I have another query,

Re: Help to understand Actual Rows vs Plan Rows from the query planner output

2018-09-24 Thread Arup Rakshit
Rakshit a...@zeit.io > On 24-Sep-2018, at 4:11 AM, Tomas Vondra wrote: > > > > On 09/23/2018 10:21 PM, Arup Rakshit wrote: >> Hello I have some questions related to the query plan output about the >> planned and actual rows. In the following example: >>

Help to understand Actual Rows vs Plan Rows from the query planner output

2018-09-23 Thread Arup Rakshit
plan i.e. Node Type: "Bitmap Heap Scan” again planner estimated rows 1? How does it counts these? What does the Loops count says us about the query? Thanks, Arup Rakshit a...@zeit.io

Re: Why my query not using index to sort?

2018-09-28 Thread Arup Rakshit
spector_tool_idx20_1 (cost=0.00..4.88 rows=81 width=0) (actual time=0.059..0.059 rows=81 loops=1) Index Cond: (company_id = '86529964-6e9b-4bfa-ba9e-62bd24eaa954'::uuid) Planning time: 1.743 ms Execution time: 0.954 ms (12 rows) Thanks, Arup Rakshit a...@zeit.io > On 28-Sep

Why my query not using index to sort?

2018-09-28 Thread Arup Rakshit
idx20_1 (cost=0.00..4.88 rows=81 width=0) (actual time=0.025..0.025 rows=81 loops=1) Index Cond: (company_id = '86529964-6e9b-4bfa-ba9e-62bd24eaa954'::uuid) Planning time: 0.168 ms Execution time: 0.533 ms Is there anyway, I can improve the sorting so that it can use the index ? Thanks, Arup Rakshit a...@zeit.io

Re: Why my query not using index to sort?

2018-09-28 Thread Arup Rakshit
Oh I see. That makes sense, I was reading too much into that line.. :) Thanks, Arup Rakshit a...@zeit.io > On 28-Sep-2018, at 9:29 PM, Andreas Kretschmer > wrote: > > > > Am 28.09.2018 um 16:49 schrieb Arup Rakshit: >> Planning time: 1.867 ms >> Execu

Re: Why my query not using index to sort?

2018-09-28 Thread Arup Rakshit
Also I meatn the execution time is less than I had before with enable_sort = off. Why 6 rows was a side question. :) Thanks, Arup Rakshit a...@zeit.io > On 28-Sep-2018, at 9:29 PM, Andreas Kretschmer > wrote: > > > > Am 28.09.2018 um 16:49 schrieb Arup Rakshit: >&g

Re: Select rows when all all ids of its children records matches

2018-09-12 Thread Arup Rakshit
Hi Rob, I figured it out. thanks. It is giving correct data. > Aren't you looking for cte.tags = array[1,2]? posts_tags_cte has tags column, so I am using it. Thanks, Arup Rakshit a...@zeit.io > On 12-Sep-2018, at 9:47 PM, Rob Sargent wrote: > > > > On 09/12/2018 10:0

Re: Select rows when all all ids of its children records matches

2018-09-12 Thread Arup Rakshit
IN is OR, I want the AND logic. Select posts which has tag 1, 2 and 3 ( tag ids ) Thanks, Arup Rakshit a...@zeit.io > On 12-Sep-2018, at 8:58 PM, Ron wrote: > > Maybe this: > select p.id, p.name > from posts p, > posts_tags pt, > tags t > where t.id i

Re: Select rows when all all ids of its children records matches

2018-09-12 Thread Arup Rakshit
Can you show me the SQL construction? Do I need to use `WITH`? Thanks, Arup Rakshit a...@zeit.io > On 12-Sep-2018, at 9:13 PM, David G. Johnston > wrote: > > On Wednesday, September 12, 2018, Arup Rakshit <mailto:a...@zeit.io>> wrote: > IN is OR, I want the AND l

Re: Select rows when all all ids of its children records matches

2018-09-12 Thread Arup Rakshit
, 2]::int8[] But it gives me all the posts. Thanks, Arup Rakshit a...@zeit.io > On 12-Sep-2018, at 9:14 PM, Arup Rakshit wrote: > > Can you show me the SQL construction? Do I need to use `WITH`? > > > Thanks, > > Arup Rakshit > a...@zeit.io <mailto:a...@zeit.io&

Bitmap Heap Scan and Bitmap Index Scan

2018-09-14 Thread Arup Rakshit
than index scan? Thanks, Arup Rakshit a...@zeit.io

Bitmap Heap Scan and Bitmap Index Scan

2018-09-15 Thread Arup Rakshit
than index scan? Thanks, Arup Rakshit a...@zeit.io

Re: Can I add Index to make a query faster which involves joins on unnest ?

2018-09-14 Thread Arup Rakshit
Hello Rob, So how do I improve this query speed? Thanks, Arup Rakshit a...@zeit.io > On 14-Sep-2018, at 12:27 AM, Rob Sargent wrote: > > > >> On Sep 13, 2018, at 12:17 PM, Arup Rakshit > <mailto:a...@zeit.io>> wrote: >> >> The below query

Can I add Index to make a query faster which involves joins on unnest ?

2018-09-13 Thread Arup Rakshit
width=32) (actual time=0.108..3.946 rows=53289 loops=1) Sort Key: t.size Sort Method: quicksort Memory: 25kB -> Function Scan on unnest t (cost=0.00..1.00 rows=100 width=32) (actual time=0.030..0.033 rows=9 loops=1) Planning time: 0.667 ms Execution time: 62.846 ms Thanks, Arup Rakshit a...@zeit.io

SQl help to build a result with custom aliased bool column

2019-04-08 Thread Arup Rakshit
= features.id It works. But is there any better way to achieve this? Thanks, Arup Rakshit a...@zeit.io

Re: SQl help to build a result with custom aliased bool column

2019-04-08 Thread Arup Rakshit
| 4|f4 | | Thanks, Arup Rakshit a...@zeit.io > On 08-Apr-2019, at 3:28 PM, Szymon Lipiński wrote: > > Hey, > you could just use > > SELECT > features.id, > features.name, > company_features.company_id = 1 as active > > reg

Re: SQl help to build a result with custom aliased bool column

2019-04-08 Thread Arup Rakshit
| t 2 | f2 | t 3 | f3 | f 3 | f3 | t 4 | f4 | f (5 rows) I should get in the results only 3, as total number of features are 3. Thanks, Arup Rakshit a...@zeit.io > On 08-Apr-2019, at 3:28 PM, Szymon Lipiński wrote: > > Hey, > you could just use > >

Re: SQl help to build a result with custom aliased bool column

2019-04-08 Thread Arup Rakshit
. The tables I created above in different schema to ask question with sample data and test the query output. So they are little inconsistent, yes you are right. Thanks, Arup Rakshit a...@zeit.io > On 08-Apr-2019, at 4:36 PM, mariusz wrote: > > bear in mind that with a large number of

duplicate key value violates unique constraint "chinese_price_infos_pkey"

2019-05-06 Thread Arup Rakshit
king_dev=# SELECT nextval('chinese_price_infos_id_seq'); nextval - 71164 (1 row) Not sure how it is out of sync. How can I fix this permanently. I ran vacuum analyze verbose; still same error. Thanks, Arup Rakshit a...@zeit.io

Re: duplicate key value violates unique constraint "chinese_price_infos_pkey"

2019-05-06 Thread Arup Rakshit
id | uuid| | | Indexes: "chinese_price_infos_pkey" PRIMARY KEY, btree (id) "index_chinese_price_infos_on_company_id" btree (company_id) Thanks, Arup Rakshit a...@zeit.io > On 06-May-2019, at 4:38 PM, Ray O'Donnell wrote: > > On 06/05/2019 12:05, Arup Rakshit wro

Re: Extend inner join to fetch not yet connected rows also

2019-09-22 Thread Arup Rakshit
OR contractor_skills.user_id IS NULL) ORDER BY "craftsmanships"."id”; But after I read yours I found mine is doing lot of unnecessary joins. Thank you. Thanks, Arup Rakshit a...@zeit.io > On 22-Sep-2019, at 5:38 PM, Jan Kohnert > wrote: > > Hey, > &

Re: Extend inner join to fetch not yet connected rows also

2019-09-22 Thread Arup Rakshit
Hi Jan, > On 22-Sep-2019, at 5:38 PM, Jan Kohnert > wrote: > > Hey, > > Am Sonntag, 22. September 2019, 13:21:46 CEST schrieb Arup Rakshit: >> I have craftsmanships table which has (id, name) and users table (id, email, >> ..). When a user has some craftsma

Re: Extend inner join to fetch not yet connected rows also

2019-09-22 Thread Arup Rakshit
> On 22-Sep-2019, at 6:55 PM, Jan Kohnert > wrote: > > Hi Arup, > > Am Sonntag, 22. September 2019, 14:48:20 CEST schrieb Arup Rakshit: >> Hi Jan, >> >>> On 22-Sep-2019, at 5:38 PM, Jan Kohnert >>> wrote: >>> maybe something like

Extend inner join to fetch not yet connected rows also

2019-09-22 Thread Arup Rakshit
---+-+- 1 | paint | t 2 | drywall | t (2 rows) But I want to list all craftsmanships and has column should have `t` when user_id #8 has it, else `f`. How can I extend thisquery? Thanks, Arup Rakshit a...@zeit.io

Create array of data from JSONB in PG 9.5

2019-11-15 Thread Arup Rakshit
When I ran the same query to production I get error: ERROR: set-valued function called in context that cannot accept a set Thanks, Arup Rakshit a...@zeit.io