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

2018-09-28 Thread Arup Rakshit
Hi,

> This is a broad topic, and I can only give you some hints.

Yes when I am reading this 
https://www.postgresql.org/docs/10/static/using-explain.html 
  I found the doc 
said like “...Plan-reading is an art that requires 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 Albe  wrote:
> 
> Arup Rakshit wrote:
>> Thanks for the link. I read the documentation you linked, and part of it
>> I understood and rest went above my head. Probably I need to read it multiple
>> times to understand what is going on. I am learning how indexing works in 
>> DBMS.
>> Mostly I understood Btree so far. I am an application developer.
>> Being an application developer I think I need to know which column should be
>> indexed and what kind of index to apply in which case.
> 
> That is true; a truth that many developers unfortunately ignore.
> 
>> Most of the time, when
>> I see slow query, I saw people ask to run the explain to see the plan.
>> And explain statement shows lot of data about the query. So my questions is 
>> that:
>> Which part I should read from the plan output to figure out reason of 
>> slowness
>> or what need to be used to improve it. What are basic things I should know 
>> about it.
>> I think, I don’t need to internal math for this, am I right? The query in
>> this post is not a slow query, it is something I ran to see how index merge 
>> happens.
>> I am asking generally. Can you give me some directions on this, so that I can
>> build up some bases on this subject.
> 
> This is a broad topic, and I can only give you some hints.
> In order to understand EXPLAIN output and to improve your query, you need
> to know some of how the database is implemented.
> 
> You have to understand index scans, index only scans and bitmap index scans.
> You have to understand nested loop, hash and merge joins.
> You have to understand table statistics, dead tuples and table bloat.
> 
> The first things to look for in EXPLAIN (ANALYZE, BUFFERS) output is in which
> nodes the time is spent, and where the estimated number of rows diverges
> significantly from the actual number of rows.
> The former are the spots where there is room for improvement, and the latter
> is often the root cause of a bad plan choice.
> Also, watch out for the nodes that touch a lot of blocks.
> They can cause intermittent slow-down if the blocks are not in cache.
> 
>> Also what are the best resources to learn GIST, GIN indexes — something which
>> teaches it from the ground up? 
> 
> The documentation, and for what goes beyond that, the source.
> 
> Yours,
> Laurenz Albe
> -- 
> Cybertec | https://www.cybertec-postgresql.com
> 



Re: Replication Issues

2018-09-28 Thread bhargav kamineni
Ee are using 9.5 version, slot option -s is not available ,can I go with -X
stream option ?

On Fri 28 Sep, 2018, 12:01 PM Laurenz Albe, 
wrote:

>  bhargav kamineni wrote:
> > Hi Team,
> >
> > I have configured replication using slot ,But it failed by throwing the
> > ERROR  pg_basebackup: could not get transaction log end position from
> server:
> > ERROR:  requested WAL segment 00012C9D0085 has already been
> removed ,
> > which is  unexpected because i have created the slot on master first
> > and then issued the base backup command from slave's end
> > the command is
> > usr/lib/postgresql/9.5/bin/pg_basebackup -U  user --max-rate='150 M'
> --progress --verbose --write-recovery-conf --status-interval='10 s' -D
> data_dir  -h host_ip  -p 5433
> > These  are the settings on my master
> > archive_mode=on
> > archive_command='/bin/true'
> > wal_keep_segments=512
> > max_wal_senders=4
> > Series of steps i have followed :
> > 1) Enabled password less authentication between master and slave
> > 2)created slot on master (assuming it will store wal's regardless of
> other settings)
> > 3)started basebackup from slave's end
> > 4)Issued checkpoint at master's end
> >
> > Here my concern is , slave should recover WAL from replication slot but
> why i
> > got the above ERROR , Why slot removed  the requested wal file , Could
> you please
> > let me know the reason why it happened or did i miss something ?
>
> I guess your base backup took long enough for the required WAL segments to
> be
> removed by the time it was done.
>
> To prevent that, create a replication slot *before* you perform
> pg_basebackup
> and use the options "-S  -X stream" of pg_basebackup.
>
> You then use the same slot in "recovery.conf".
>
> That way you cannot lose any WAL.
>
> Yours,
> Laurenz Albe
> --
> Cybertec | https://www.cybertec-postgresql.com
>
>


Re: Replication Issues

2018-09-28 Thread Achilleas Mantzios

On 28/9/18 1:50 μ.μ., bhargav kamineni wrote:

Ee are using 9.5 version, slot option -s is not available ,can I go with -X 
stream option ?

-S is intended when you plan to use the backup as a hot standby, when you must 
use the same replication slot.
If you plan to use the backup as a stand alone backup you don't need this 
option anyway.


On Fri 28 Sep, 2018, 12:01 PM Laurenz Albe, mailto:laurenz.a...@cybertec.at>> wrote:

 bhargav kamineni wrote:
> Hi Team,
>
> I have configured replication using slot ,But it failed by throwing the
> ERROR  pg_basebackup: could not get transaction log end position from 
server:
> ERROR:  requested WAL segment 00012C9D0085 has already been 
removed ,
> which is  unexpected because i have created the slot on master first
> and then issued the base backup command from slave's end
> the command is
> usr/lib/postgresql/9.5/bin/pg_basebackup -U  user --max-rate='150 M' 
--progress --verbose --write-recovery-conf --status-interval='10 s' -D data_dir  
-h host_ip  -p 5433
> These  are the settings on my master
> archive_mode=on
> archive_command='/bin/true'
> wal_keep_segments=512
> max_wal_senders=4
> Series of steps i have followed :
> 1) Enabled password less authentication between master and slave
> 2)created slot on master (assuming it will store wal's regardless of 
other settings)
> 3)started basebackup from slave's end
> 4)Issued checkpoint at master's end
>
> Here my concern is , slave should recover WAL from replication slot but 
why i
> got the above ERROR , Why slot removed  the requested wal file , Could 
you please
> let me know the reason why it happened or did i miss something ?

I guess your base backup took long enough for the required WAL segments to 
be
removed by the time it was done.

To prevent that, create a replication slot *before* you perform 
pg_basebackup
and use the options "-S  -X stream" of pg_basebackup.

You then use the same slot in "recovery.conf".

That way you cannot lose any WAL.

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com





--
Achilleas Mantzios
IT DEV Lead
IT DEPT
Dynacom Tankers Mgmt



Why my query not using index to sort?

2018-09-28 Thread Arup Rakshit
My query is not using name index to sort the result.

explain analyze select
"vessels" .*
from
"vessels"
where
"vessels"."deleted_at" is null
and "vessels"."company_id" = '86529964-6e9b-4bfa-ba9e-62bd24eaa954'
order by
"vessels"."name" ASC;

I have below index in my vessels table:

Indexes:
"vessels_pkey" PRIMARY KEY, btree (id)
"inspector_tool_idx20_1" btree (company_id)
"inspector_tool_idx20_2" btree (name)


and following is my plan output.

Sort  (cost=17.29..17.48 rows=76 width=107) (actual time=0.468..0.473 rows=77 
loops=1)
  Sort Key: name
  Sort Method: quicksort  Memory: 38kB
  ->  Bitmap Heap Scan on vessels  (cost=4.90..14.91 rows=76 width=107) (actual 
time=0.036..0.059 rows=77 loops=1)
Recheck Cond: (company_id = 
'86529964-6e9b-4bfa-ba9e-62bd24eaa954'::uuid)
Filter: (deleted_at IS NULL)
Rows Removed by Filter: 4
Heap Blocks: exact=3
->  Bitmap Index Scan on inspector_tool_idx20_1  (cost=0.00..4.88 
rows=81 width=0) (actual time=0.022..0.023 rows=81 loops=1)
  Index Cond: (company_id = 
'86529964-6e9b-4bfa-ba9e-62bd24eaa954'::uuid)
Planning time: 0.178 ms
Execution time: 0.527 ms



After that I changed my index as follows, and the got almost same plan output.


Indexes:
"vessels_pkey" PRIMARY KEY, btree (id)
"inspector_tool_idx20_1" btree (company_id, name)

Sort  (cost=17.29..17.48 rows=76 width=107) (actual time=0.475..0.480 rows=77 
loops=1)
  Sort Key: name
  Sort Method: quicksort  Memory: 38kB
  ->  Bitmap Heap Scan on vessels  (cost=4.90..14.91 rows=76 width=107) (actual 
time=0.038..0.058 rows=77 loops=1)
Recheck Cond: (company_id = 
'86529964-6e9b-4bfa-ba9e-62bd24eaa954'::uuid)
Filter: (deleted_at IS NULL)
Rows Removed by Filter: 4
Heap Blocks: exact=3
->  Bitmap Index Scan on inspector_tool_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 Ravi Krishna


> Is there anyway, I can improve the sorting so that it can use the index ?

Are you telling that why PG is not simply reading the data from the index 
(which is already in sorted
order)?




Re: How to maintain the csv log files in pg_log directory only for past 30 days

2018-09-28 Thread Adrian Klaver

On 9/27/18 10:25 PM, Michael Paquier wrote:

On Fri, Sep 28, 2018 at 10:33:30AM +0530, Raghavendra Rao J S V wrote:

Log file will be generated in *csv* format at *pg_log* directory in our
PostgreSQL. Every day we are getting one log file. We would like to
maintain only max 30 days. Which setting need to modify by us in
“postgresql.conf” in order to recycle the log files after 30 days.


If you use for example log_filename = 'postgresql-%d.log', then the
server uses one new file every day.  This truncates the contents from
the last month automatically.


If log_truncate_on_rotation = 'on', correct?


--
Michael




--
Adrian Klaver
adrian.kla...@aklaver.com



Re: Why my query not using index to sort?

2018-09-28 Thread Arup Rakshit
Hi Ravi,


Yes you are right. It seems it is doing sorting in memory by name. But I have 
`name` column in index.


Thanks,

Arup Rakshit
a...@zeit.io



> On 28-Sep-2018, at 6:38 PM, Ravi Krishna  wrote:
> 
> 
>> Is there anyway, I can improve the sorting so that it can use the index ?
> 
> Are you telling that why PG is not simply reading the data from the index 
> (which is already in sorted
> order)?
> 



Re: How to maintain the csv log files in pg_log directory only for past 30 days

2018-09-28 Thread Francisco Olarte
On Fri, Sep 28, 2018 at 7:03 AM, Raghavendra Rao J S V
 wrote:
> Log file will be generated in csv format at pg_log directory in our
> PostgreSQL. Every day we are getting one log file. We would like to maintain
> only max 30 days. Which setting need to modify by us in “postgresql.conf” in
> order to recycle the log files after 30 days.

I have similar problems in a lot of things and normally use "find
 -name  -mtime + -delete" in the daemons
cron ( gnu find, on linux, I assume other os have a similar command ).

For postgres-only solutions you've been given some advice previously,
and like those I only know ways to do it daily/weekly/monthly/yearly.

Francisco Olarte.



Re: How to maintain the csv log files in pg_log directory only for past 30 days

2018-09-28 Thread Ron

On 09/28/2018 12:03 AM, Raghavendra Rao J S V wrote:


Hi All,

Log file will be generated in *csv* format at *pg_log* directory in our 
PostgreSQL. Every day we are getting one log file. We would like to 
maintain only max 30 days. Which setting need to modify by us in 
“postgresql.conf” in order to recycle the log files after 30 days.


Does it have to be in postgresql.conf?  A cron job which runs a few minutes 
after midnight works just fine.


Compresses yesterday's log file and deletes files older than 30 days:
#!/bin/bash
DIR=/var/lib/pgsql/data/pg_log
cd $DIR
PREVDT=$(date -d "-1 day" +"%F")
bzip2 -9 postgresql-${PREVDT}.log
OLDFILES=$(find $DIR/postgresql-*log* -mtime +30)
rm -v $OLDFILES



--
Angular momentum makes the world go 'round.


Re: Why my query not using index to sort?

2018-09-28 Thread Adrian Klaver

On 9/28/18 6:19 AM, Arup Rakshit wrote:

Hi Ravi,


Yes you are right. It seems it is doing sorting in memory by name. But I 
have `name` column in index.


You are looking for the vessels.company_id not vessels.name so not sure 
why you expect an index lookup on name?





Thanks,

Arup Rakshit
a...@zeit.io 



On 28-Sep-2018, at 6:38 PM, Ravi Krishna > wrote:




Is there anyway, I can improve the sorting so that it can use the index ?


Are you telling that why PG is not simply reading the data from the 
index (which is already in sorted

order)?






--
Adrian Klaver
adrian.kla...@aklaver.com



Re: Why my query not using index to sort?

2018-09-28 Thread Tom Lane
Arup Rakshit  writes:
> My query is not using name index to sort the result.

Given the rowcounts here, I think the planner is making the right choice.
Sorting 70-some rows with a Sort node is probably cheaper than doing
random disk I/O to get them in sorted order.  With more rows involved,
it might make the other choice.

As a testing measure (don't do it in production!), you could set
enable_sort = off, which will force the planner to pick a non-Sort
plan if possible.  Then you could see whether that's actually faster
or slower, and by how much.

regards, tom lane



Re: Why my query not using index to sort?

2018-09-28 Thread Arup Rakshit
Hello Tom,

Here is the plan with `enable_sort = off`.

# set enable_sort = off;

   SET
# explain analyze select "vessels" .* from "vessels" where 
"vessels"."deleted_at" is null and "vessels"."company_id" = 
'86529964-6e9b-4bfa-ba9e-62bd24eaa954' order by "vessels"."name" ASC;
 QUERY PLAN
-
 Index Scan using inspector_tool_idx20_1 on vessels  (cost=0.27..40.76 rows=76 
width=107) (actual time=0.047..0.120 rows=77 loops=1)
   Index Cond: (company_id = '86529964-6e9b-4bfa-ba9e-62bd24eaa954'::uuid)
   Filter: (deleted_at IS NULL)
   Rows Removed by Filter: 4
 Planning time: 1.867 ms
 Execution time: 0.252 ms
(6 rows)

Why it is showing *6 rows*? Also it seems less than what I had before:

# explain analyze select "vessels" .* from "vessels" where 
"vessels"."deleted_at" is null and "vessels"."company_id" = 
'86529964-6e9b-4bfa-ba9e-62bd24eaa954' order by "vessels"."name" ASC;
  QUERY PLAN
---
 Sort  (cost=17.29..17.48 rows=76 width=107) (actual time=0.789..0.796 rows=77 
loops=1)
   Sort Key: name
   Sort Method: quicksort  Memory: 38kB
   ->  Bitmap Heap Scan on vessels  (cost=4.90..14.91 rows=76 width=107) 
(actual time=0.090..0.122 rows=77 loops=1)
 Recheck Cond: (company_id = 
'86529964-6e9b-4bfa-ba9e-62bd24eaa954'::uuid)
 Filter: (deleted_at IS NULL)
 Rows Removed by Filter: 4
 Heap Blocks: exact=3
 ->  Bitmap Index Scan on inspector_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-2018, at 7:07 PM, Tom Lane  wrote:
> 
> Arup Rakshit  writes:
>> My query is not using name index to sort the result.
> 
> Given the rowcounts here, I think the planner is making the right choice.
> Sorting 70-some rows with a Sort node is probably cheaper than doing
> random disk I/O to get them in sorted order.  With more rows involved,
> it might make the other choice.
> 
> As a testing measure (don't do it in production!), you could set
> enable_sort = off, which will force the planner to pick a non-Sort
> plan if possible.  Then you could see whether that's actually faster
> or slower, and by how much.
> 
>   regards, tom lane



regarding bdr extension

2018-09-28 Thread Durgamahesh Manne
Hi

This is regarding bdr extension issue. I got below error at the time i have
tried to create the bdr extention


ERROR: could not open extension control file
"opt/PostgreSQL/10/share/postgresql/extension/bdr.control": No such file or
directory



Regards
Durgamahesh Manne


Re: Why my query not using index to sort?

2018-09-28 Thread Andreas Kretschmer




Am 28.09.2018 um 16:49 schrieb Arup Rakshit:

 Planning time: 1.867 ms
 Execution time: 0.252 ms
(6 rows)

Why it is showing *6 rows*? Also it seems less than what I had before:



the explain-output are 6 rows ;-)


Regards, Andreas

--
2ndQuadrant - The PostgreSQL Support Company.
www.2ndQuadrant.com




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
>>  Execution time: 0.252 ms
>> (6 rows)
>> 
>> Why it is showing *6 rows*? Also it seems less than what I had before:
>> 
> 
> the explain-output are 6 rows ;-)
> 
> 
> Regards, Andreas
> 
> -- 
> 2ndQuadrant - The PostgreSQL Support Company.
> www.2ndQuadrant.com
> 
> 



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:
>>  Planning time: 1.867 ms
>>  Execution time: 0.252 ms
>> (6 rows)
>> 
>> Why it is showing *6 rows*? Also it seems less than what I had before:
>> 
> 
> the explain-output are 6 rows ;-)
> 
> 
> Regards, Andreas
> 
> -- 
> 2ndQuadrant - The PostgreSQL Support Company.
> www.2ndQuadrant.com
> 
> 



Re: Why my query not using index to sort?

2018-09-28 Thread Andreas Kretschmer




Am 28.09.2018 um 18:03 schrieb Arup Rakshit:
Also I meatn the execution time is less than I had before with 
enable_sort = off. 


yeah, but not that much. different plan.


Regards, Andreas

--
2ndQuadrant - The PostgreSQL Support Company.
www.2ndQuadrant.com




Re: regarding bdr extension

2018-09-28 Thread Adrian Klaver

On 9/28/18 8:41 AM, Durgamahesh Manne wrote:

Hi

This is regarding bdr extension issue. I got below error at the time i 
have tried to create the bdr extention



ERROR: could not open extension control file 
"opt/PostgreSQL/10/share/postgresql/extension/bdr.control": No such file 
or directory


OS and version?

How are you installing BDR, from package or source?

What was the exact command that led to the error?

Does opt/PostgreSQL/10/share/postgresql/extension/bdr.control exist?





Regards
Durgamahesh Manne



--
Adrian Klaver
adrian.kla...@aklaver.com



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 Rakshit:
>> Also I meatn the execution time is less than I had before with enable_sort = 
>> off. 
> 
> yeah, but not that much. different plan.
> 
> 
> Regards, Andreas
> 
> -- 
> 2ndQuadrant - The PostgreSQL Support Company.
> www.2ndQuadrant.com
> 



Re: Why my query not using index to sort?

2018-09-28 Thread Adrian Klaver

On 9/28/18 11:32 AM, Arup Rakshit wrote:
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.


That is not what you showed in your first post:

Planning time: 0.178 ms
Execution time: 0.527 ms






Thanks,

Arup Rakshit
a...@zeit.io 



On 28-Sep-2018, at 9:46 PM, Andreas Kretschmer 
mailto:andr...@a-kretschmer.de>> wrote:




Am 28.09.2018 um 18:03 schrieb Arup Rakshit:
Also I meatn the execution time is less than I had before with 
enable_sort = off.


yeah, but not that much. different plan.


Regards, Andreas

--
2ndQuadrant - The PostgreSQL Support Company.
www.2ndQuadrant.com 






--
Adrian Klaver
adrian.kla...@aklaver.com



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 improve it, so that it can be finished in 0.xx 
>> ms. It takes now between 1.7 to 1.9 ms in production.
> 
> That is not what you showed in your first post:
> 
> Planning time: 0.178 ms
> Execution time: 0.527 ms
> 
> 
> 
>> 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 Rakshit:
 Also I meatn the execution time is less than I had before with enable_sort 
 = off.
>>> 
>>> yeah, but not that much. different plan.
>>> 
>>> 
>>> Regards, Andreas
>>> 
>>> -- 
>>> 2ndQuadrant - The PostgreSQL Support Company.
>>> www.2ndQuadrant.com 
>>> 
> 
> 
> -- 
> Adrian Klaver
> adrian.kla...@aklaver.com



Re: Why my query not using index to sort?

2018-09-28 Thread Rob Sargent




On 09/28/2018 12:51 PM, Arup Rakshit wrote:


Yes, I have shown the explain plan output. But in my application log 
the sql query prints 1.7 to 1.9 ms.



How often does the production app make this call?  Apparently it could 
do it 500 times per second.  But at such a rate the network overhead 
would be stupendous - you might think about getting more data per call, 
few calls.




Re: Why my query not using index to sort?

2018-09-28 Thread Adrian Klaver

On 9/28/18 11:51 AM, Arup Rakshit wrote:


Yes, I have shown the explain plan output. But in my application log the 
sql query prints 1.7 to 1.9 ms.


So you have added another layer to the process.

The application is?

The log settings are?

What is being printed?

Where is it being printed?




Thanks,

Arup Rakshit
a...@zeit.io 





--
Adrian Klaver
adrian.kla...@aklaver.com



Re: Why my query not using index to sort?

2018-09-28 Thread Arup Rakshit
Hi Adrian,

> The application is?

It is Ruby On Rails application

> The log settings are?
> Where is it being printed?

The default application log, the production.log file.

> What is being printed?

Check the gist: 
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 application log the sql 
>> query prints 1.7 to 1.9 ms.
> 
> So you have added another layer to the process.
> 
> The application is?
> 
> The log settings are?
> 
> What is being printed?
> 
> Where is it being printed?
> 
>> Thanks,
>> Arup Rakshit
>> a...@zeit.io 
> 
> 
> 
> -- 
> Adrian Klaver
> adrian.kla...@aklaver.com



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
a...@zeit.io



> On 29-Sep-2018, at 12:40 AM, Arup Rakshit  wrote:
> 
> Hi Adrian,
> 
> > The application is?
> 
> It is Ruby On Rails application
> 
> > The log settings are?
> > Where is it being printed?
> 
> The default application log, the production.log file.
> 
> > What is being printed?
> 
> Check the gist: 
> 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 application log the 
>>> sql query prints 1.7 to 1.9 ms.
>> 
>> So you have added another layer to the process.
>> 
>> The application is?
>> 
>> The log settings are?
>> 
>> What is being printed?
>> 
>> Where is it being printed?
>> 
>>> Thanks,
>>> Arup Rakshit
>>> a...@zeit.io  >> >
>> 
>> 
>> 
>> -- 
>> Adrian Klaver
>> adrian.kla...@aklaver.com 
> 



Re: Why my query not using index to sort?

2018-09-28 Thread Adrian Klaver

On 9/28/18 12:14 PM, Arup Rakshit wrote:
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.


Do you know what Vessel Load () is actually measuring?

To me it looks like it is covering both the query(including ROR 
overhead) and the HTTP request/response cycle.


Also have you looked at:

https://guides.rubyonrails.org/debugging_rails_applications.html#impact-of-logs-on-performance



Thanks,

Arup Rakshit
a...@zeit.io 




--
Adrian Klaver
adrian.kla...@aklaver.com



ORM

2018-09-28 Thread marcelo
For a new big and convoluted project I (am/was) using Devart´s 
LinqConnect as ORM.
But today I experienced some inexplicable "object reference not set to 
an instance of an object" exceptions or other more specific to this 
libraries.

I would wish to change the ORM.
Some experiences would be appreciated. Of course, I prefer open source 
software, at least to chase errors thru debugging.

TIA

---
El software de antivirus Avast ha analizado este correo electrónico en busca de 
virus.
https://www.avast.com/antivirus




Re: How to maintain the csv log files in pg_log directory only for past 30 days

2018-09-28 Thread Michael Paquier
On Fri, Sep 28, 2018 at 06:19:16AM -0700, Adrian Klaver wrote:
> If log_truncate_on_rotation = 'on', correct?

Yup, thanks for precising.
--
Michael


signature.asc
Description: PGP signature


Re: ORM

2018-09-28 Thread Adrian Klaver

On 9/28/18 3:49 PM, marcelo wrote:
For a new big and convoluted project I (am/was) using Devart´s 
LinqConnect as ORM.
But today I experienced some inexplicable "object reference not set to 
an instance of an object" exceptions or other more specific to this 
libraries.

I would wish to change the ORM.
Some experiences would be appreciated. Of course, I prefer open source 
software, at least to chase errors thru debugging.


Information that might help folks steer you to alternatives:

1) What programming language(s) are you using?

2) The OS'es involved

3) Are you using any frameworks between the database and the end user?

4) Is an ORM even necessary?



TIA

---
El software de antivirus Avast ha analizado este correo electrónico en 
busca de virus.

https://www.avast.com/antivirus






--
Adrian Klaver
adrian.kla...@aklaver.com



Re: How to maintain the csv log files in pg_log directory only for past 30 days

2018-09-28 Thread Raghavendra Rao J S V
Hi All,

Hope you all are recommending below settings to maintain only max 30 days
logs in *pg_log* directory. Please correct me if I am wrong.

log_filename = 'postgresql-%d.log'
log_truncate_on_rotation = 'on',

Regards,
Raghavendra Rao

On Sat, 29 Sep 2018 at 04:24, Michael Paquier  wrote:

> On Fri, Sep 28, 2018 at 06:19:16AM -0700, Adrian Klaver wrote:
> > If log_truncate_on_rotation = 'on', correct?
>
> Yup, thanks for precising.
> --
> Michael
>


-- 
Regards,
Raghavendra Rao J S V
Mobile- 8861161425