Why is it OK for dbsize.c to look at relation files directly?

2019-04-24 Thread Andres Freund
Hi, To me it seems like a noticable layering violation for dbsize.c to directly stat() files in the filesystem, without going through smgr.c. And now tableam. This means there's code knowing about file segments outside of md.c - which imo shouldn't be the case. We also stat a lot more than neces

Why is it OK for dbsize.c to look at relation files directly?

2019-04-24 Thread Andres Freund
Hi, To me it seems like a noticable layering violation for dbsize.c to directly stat() files in the filesystem, without going through smgr.c. And now tableam. This means there's code knowing about file segments outside of md.c - which imo shouldn't be the case. We also stat a lot more than neces

Re: Why is it OK for dbsize.c to look at relation files directly?

2019-04-24 Thread Michael Paquier
On Wed, Apr 24, 2019 at 04:09:56PM -0700, Andres Freund wrote: > I think we should change dbsize.c to call > RelationGetNumberOfBlocksInFork() for relkinds != TABLE/TOAST/MATVIEW, > and a new AM callback for those. Probably with the aforementioned > additional logic of closing smgr references if th

Re: Why is it OK for dbsize.c to look at relation files directly?

2019-04-24 Thread Andres Freund
On 2019-04-25 09:16:50 +0900, Michael Paquier wrote: > Perhaps you should add a TODO item for that? Just so it's guaranteed that it'll never happen? :)

Re: Why is it OK for dbsize.c to look at relation files directly?

2019-04-24 Thread Michael Paquier
On Wed, Apr 24, 2019 at 05:18:08PM -0700, Andres Freund wrote: > Just so it's guaranteed that it'll never happen? :) Items get done, from time to time... b0eaa4c is one rare example :p /me runs and hides. -- Michael signature.asc Description: PGP signature

Re: Why is it OK for dbsize.c to look at relation files directly?

2019-04-25 Thread Tomas Vondra
On Thu, Apr 25, 2019 at 09:25:03AM +0900, Michael Paquier wrote: On Wed, Apr 24, 2019 at 05:18:08PM -0700, Andres Freund wrote: Just so it's guaranteed that it'll never happen? :) Items get done, from time to time... b0eaa4c is one rare example :p /me runs and hides. IMO this is one of the

Re: Why is it OK for dbsize.c to look at relation files directly?

2019-04-24 Thread Michael Paquier
On Wed, Apr 24, 2019 at 04:09:56PM -0700, Andres Freund wrote: > I think we should change dbsize.c to call > RelationGetNumberOfBlocksInFork() for relkinds != TABLE/TOAST/MATVIEW, > and a new AM callback for those. Probably with the aforementioned > additional logic of closing smgr references if th

Re: Why is it OK for dbsize.c to look at relation files directly?

2019-04-24 Thread Andres Freund
On 2019-04-25 09:16:50 +0900, Michael Paquier wrote: > Perhaps you should add a TODO item for that? Just so it's guaranteed that it'll never happen? :)

Re: Why is it OK for dbsize.c to look at relation files directly?

2019-04-24 Thread Michael Paquier
On Wed, Apr 24, 2019 at 05:18:08PM -0700, Andres Freund wrote: > Just so it's guaranteed that it'll never happen? :) Items get done, from time to time... b0eaa4c is one rare example :p /me runs and hides. -- Michael signature.asc Description: PGP signature

Re: Why is it OK for dbsize.c to look at relation files directly?

2019-04-25 Thread Tomas Vondra
On Thu, Apr 25, 2019 at 09:25:03AM +0900, Michael Paquier wrote: On Wed, Apr 24, 2019 at 05:18:08PM -0700, Andres Freund wrote: Just so it's guaranteed that it'll never happen? :) Items get done, from time to time... b0eaa4c is one rare example :p /me runs and hides. IMO this is one of the