Re: Help regarding Multi Tenancy with PostgreSQL

2022-08-15 Thread Abdul Qoyyuum
Here's a doc resource for you to look at resources with varied approaches (also including docker per tenant): https://books.agiliq.com/projects/django-multi-tenant/en/latest/ On Mon, Aug 15, 2022 at 9:58 PM Gaurav Daunde wrote: > Hi All, > > We are planing to implement multitenancy solution to

Re: ***SPAM*** Re: Can I get the number of results plus the results with a single query?

2022-08-15 Thread Rob Sargent
On 8/15/22 14:37, Perry Smith wrote: On Aug 15, 2022, at 08:55, David G. Johnston wrote: On Monday, August 15, 2022, Perry Smith wrote: I’ve been toying with row_number() and then sort by row_number descending and pick off the first row as the total number. Use count as a

Re: ***SPAM*** Re: Can I get the number of results plus the results with a single query?

2022-08-15 Thread Perry Smith
> On Aug 15, 2022, at 08:55, David G. Johnston > wrote: > > On Monday, August 15, 2022, Perry Smith > wrote: > I’ve been toying with row_number() and then sort by row_number descending and > pick off the first row as the total number. > > Use count as a window

Re: Can I get the number of results plus the results with a single query?

2022-08-15 Thread Bryn Llewellyn
>>> p...@easesoftware.com wrote: >>> >>> Currently I’m doing this with two queries such as: >>> >>> SELECT COUNT(*) FROM table WHERE …. expression … >>> SELECT * FROM table WHERE …. expression … >>> >>> But this requires two queries. Is there a way to do

Re: Can I get the number of results plus the results with a single query?

2022-08-15 Thread Peter J. Holzer
On 2022-08-15 08:49:33 -0500, Perry Smith wrote: > I like to have what I call “baby sitting” messages such as “Completed > 15 out of 1023”. To do this, I need the number of results a query > returns but I also need the results. > > Currently I’m doing this with two queries such as: > >

Re: lateral join with union all

2022-08-15 Thread David G. Johnston
On Mon, Aug 15, 2022 at 8:53 AM jian he wrote: > select * from > ( > (select 2 as v ) > union all > (select 3 as v) > ) as q1 > cross join lateral > ( (select * from > ((select 4 as v) union all > (select 5 as v)) as q3 > ) > union all > (select q1.v) > ) as

lateral join with union all

2022-08-15 Thread jian he
select * from ( (select 2 as v ) union all (select 3 as v) ) as q1 cross join lateral ( (select * from ((select 4 as v) union all (select 5 as v)) as q3 ) union all (select q1.v) ) as q2; I thought q1 will be materialized as a constant set and will be equivalent

Help regarding Multi Tenancy with PostgreSQL

2022-08-15 Thread Gaurav Daunde
Hi All, We are planing to implement multitenancy solution to store client's data seperately. We uses Django Rest Framework as backend with Postgresql version 12.11 . Is Single database multiple schemas a good solution? Is this solution works fine with django migrations? OR there can be much

Re: Can I get the number of results plus the results with a single query?

2022-08-15 Thread David G. Johnston
On Monday, August 15, 2022, Perry Smith wrote: > > I’ve been toying with row_number() and then sort by row_number descending > and pick off the first row as the total number. > Use count as a window function. David J.

Can I get the number of results plus the results with a single query?

2022-08-15 Thread Perry Smith
I like to have what I call “baby sitting” messages such as “Completed 15 out of 1023”. To do this, I need the number of results a query returns but I also need the results. Currently I’m doing this with two queries such as: SELECT COUNT(*) FROM table WHERE …. expression … SELECT *

RE: Unable to start replica after failover

2022-08-15 Thread Lahnov, Igor
What additional information is needed?    

Re: limits, indexes, views and query planner

2022-08-15 Thread David Rowley
On Mon, 15 Aug 2022 at 20:30, Marc Mamin wrote: > in the example below, we can see that the view test_ab prevents the usage of > the index to retrieve the top last rows. > This is a special case, as the where clause excludes data from the second > table, and the explain output do not references

limits, indexes, views and query planner

2022-08-15 Thread Marc Mamin
hello, in the example below, we can see that the view test_ab prevents the usage of the index to retrieve the top last rows. This is a special case, as the where clause excludes data from the second table, and the explain output do not references it at all. I wonder if the planner could be able