pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Empty materialized view
12+ messages / 3 participants
[nested] [flat]

* Empty materialized view
@ 2024-03-24 18:12  Thiemo Kellner <thiemo@gelassene-pferde.biz>
  0 siblings, 2 replies; 12+ messages in thread

From: Thiemo Kellner @ 2024-03-24 18:12 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

Hi

I have created a materialized view with "with data". And I refreshed it 
with "with data". The query of the mv returns records when executed 
outside the mv. I would appreciate help with respect to what I miss that 
my mv is empty. You might want to have a look at the code attached.

Kind regards

Thiemo

Attachments:

  snowrunner.7z (application/x-compressed, 32.7K) download

^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: Empty materialized view
@ 2024-03-24 19:56  Erik Wienhold <ewie@ewie.name>
  parent: Thiemo Kellner <thiemo@gelassene-pferde.biz>
  1 sibling, 1 reply; 12+ messages in thread

From: Erik Wienhold @ 2024-03-24 19:56 UTC (permalink / raw)
  To: Thiemo Kellner <thiemo@gelassene-pferde.biz>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

On 2024-03-24 19:12 +0100, Thiemo Kellner wrote:
> I have created a materialized view with "with data". And I refreshed it with
> "with data". The query of the mv returns records when executed outside the
> mv. I would appreciate help with respect to what I miss that my mv is empty.

Maybe you executed REFRESH in a transaction but did not commit it?

> You might want to have a look at the code attached.

I can't find any materialized view in your archive.

-- 
Erik





^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: Empty materialized view
@ 2024-03-24 20:07  Adrian Klaver <adrian.klaver@aklaver.com>
  parent: Thiemo Kellner <thiemo@gelassene-pferde.biz>
  1 sibling, 0 replies; 12+ messages in thread

From: Adrian Klaver @ 2024-03-24 20:07 UTC (permalink / raw)
  To: Thiemo Kellner <thiemo@gelassene-pferde.biz>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

On 3/24/24 11:12, Thiemo Kellner wrote:
> Hi
> 
> I have created a materialized view with "with data". And I refreshed it 
> with "with data". The query of the mv returns records when executed 
> outside the mv. I would appreciate help with respect to what I miss that 
> my mv is empty. You might want to have a look at the code attached.

That does not contain the statements mentioned above. Provide a simple 
test case as code inline to your reply.

> 
> Kind regards
> 
> Thiemo

-- 
Adrian Klaver
adrian.klaver@aklaver.com






^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: Empty materialized view
@ 2024-03-24 20:11  Thiemo Kellner <thiemo@gelassene-pferde.biz>
  parent: Erik Wienhold <ewie@ewie.name>
  0 siblings, 1 reply; 12+ messages in thread

From: Thiemo Kellner @ 2024-03-24 20:11 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>



Am 24.03.2024 um 20:56 schrieb Erik Wienhold:
> Maybe you executed REFRESH in a transaction but did not commit it?

While I can see the point for the refresh (but there actually is a 
commit), I cannot hold it valid for a create with data when the mv 
actually is created (confirmed by being empty).

> I can't find any materialized view in your archive.

Oh sh*. That is the file, I forgot to commit. Please find it attached now.

Attachments:

QUERY_PER_TASK⠒MV.pg_sql (text/plain, 4.0K) download \echo Set materialised view QUERY_PER_TASK⠒MV up drop materialized view if exists QUERY_PER_TASK⠒MV; create materialized view QUERY_PER_TASK⠒MV as select TDP.TOP_LEVEL_TASK_TYPE⠒NAME, TDP.TOP_LEVEL_TASK⠒NAME, TDP.TASK_TREE⠒HIGHEST_PRIORITY, TDP.TASK⠒NAME, TDP.TASK_TYPE⠒NAME, TDP.TASK⠒PRIORITY, TDP.TASK⠒DESCRIPTION, TDP.GOOD⠒NAME, TDP.GOOD_4_THIS_TASK, TDP.QUANTITY⠒DROP_OFF, TDP.QUANTITY⠒NEEDED_4_THIS_REGION, TDP.QUANTITY⠒NEEDED_4_THIS_TASK_TREE, TDP.QUANTITY⠒PICK_UP, TDP.QUANTITY⠒READY_4_THIS_REGION, TDP.GOOD⠒SIZE, TDP.GOOD⠒SIZE * TDP.QUANTITY⠒DROP_OFF as NEEDED_TRANSPORT_CAPACITY_4_THIS_TASK, TDP.NEEDED_TRANSPORT_CAPACITY_4_THIS_REGION, TDP.NEEDED_TRANSPORT_CAPACITY_4_THIS_TASK_TREE, case TDP.NODE_TYPE⠒NAME⠒PICK_UP when 'Crafting zone' then R.GOOD⠒RESOURCE⠒NAME else null end as GOOD⠒RESOURCE⠒NAME, P.QUANTITY⠒READY_4_THIS_REGION as RESOURCE_QUANTITY⠒READY_4_THIS_REGION, TDP.NODE⠒MAP⠒NAME⠒DROP_OFF, TDP.NODE⠒NAME⠒DROP_OFF, TDP.NODE⠒MAP⠒NAME⠒PICK_UP, TDP.NODE⠒NAME⠒PICK_UP, P.NODE⠒MAP⠒NAME as NODE⠒MAP⠒NAME⠒PICK_UP_RESOURCE, P.NODE⠒NAME as NODE⠒NAME⠒PICK_UP_RESOURCE, TDP.DIRECTION⠒CODE⠒DROP_OFF, TDP.CENTRICITY⠒NAME⠒DROP_OFF, TDP.DIRECTION⠒CODE⠒PICK_UP, TDP.CENTRICITY⠒NAME⠒PICK_UP, TDP.NODE⠒DESCRIPTION⠒DROP_OFF, TDP.PICK_UP⠒DESCRIPTION, TDP.NODE⠒DESCRIPTION⠒PICK_UP, TDP.DIRECTION⠒DESCRIPTION⠒DROP_OFF, TDP.CENTRICITY⠒DESCRIPTION⠒DROP_OFF, TDP.DIRECTION⠒DESCRIPTION⠒PICK_UP, TDP.CENTRICITY⠒DESCRIPTION⠒PICK_UP, P.DIRECTION⠒DESCRIPTION as DIRECTION⠒DESCRIPTION⠒PICK_UP_RESOURCE, P.CENTRICITY⠒DESCRIPTION as CENTRICITY⠒DESCRIPTION⠒PICK_UP_RESOURCE, TDP.GOOD⠒DESCRIPTION, TDP.GOOD⠒WEIGHT, TDP.PATH, TDP.REGION⠒NAME, TDP.TOP_LEVEL_TASK⠒PRIORITY, TDP.REGION⠒ID, TDP.TASK_PREDECESSOR⠒ID, TDP.TASK⠒ID, TDP.LEVEL, TDP.GOOD⠒ID from SNOWRUNNER.TASK_HIERARCHY_DROP_OFF_PICK_UP_AVAIL⠒V TDP left outer join SNOWRUNNER.PRODUCTION⠒V R on 1 = 1 and TDP.GOOD⠒ID = R.GOOD⠒PRODUCT⠒ID and TDP.REGION⠒ID = R.REGION⠒ID left outer join SNOWRUNNER.PICK_UP⠒V P on 1 = 1 and R.GOOD⠒RESOURCE⠒ID = P.GOOD⠒ID and R.REGION⠒ID = P.REGION⠒ID where 1 = 1 order by TDP.REGION⠒NAME asc, TASK_TREE⠒HIGHEST_PRIORITY asc, NODE⠒MAP⠒NAME⠒DROP_OFF asc, NODE⠒MAP⠒NAME⠒PICK_UP asc, NODE⠒MAP⠒NAME⠒PICK_UP asc, NODE⠒MAP⠒NAME⠒PICK_UP_RESOURCE asc, NODE⠒NAME⠒PICK_UP_RESOURCE asc, GOOD⠒NAME asc, NODE⠒MAP⠒NAME⠒DROP_OFF asc, PATH asc with data; refresh materialized view QUERY_PER_TASK⠒MV with data; comment on materialized view QUERY_PER_TASK⠒MV is ' $Header$'; commit;
^ permalink raw reply [nested|flat] 12+ messages in thread

* Re: Empty materialized view
@ 2024-03-24 20:30  Adrian Klaver <adrian.klaver@aklaver.com>
  parent: Thiemo Kellner <thiemo@gelassene-pferde.biz>
  0 siblings, 1 reply; 12+ messages in thread

From: Adrian Klaver @ 2024-03-24 20:30 UTC (permalink / raw)
  To: Thiemo Kellner <thiemo@gelassene-pferde.biz>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

On 3/24/24 13:11, Thiemo Kellner wrote:
> 
> 
> Am 24.03.2024 um 20:56 schrieb Erik Wienhold:
>> Maybe you executed REFRESH in a transaction but did not commit it?
> 
> While I can see the point for the refresh (but there actually is a 
> commit), I cannot hold it valid for a create with data when the mv 
> actually is created (confirmed by being empty).

Confirmed in the same session that created it or in a different session?

> 
>> I can't find any materialized view in your archive.
> 
> Oh sh*. That is the file, I forgot to commit. Please find it attached now.

-- 
Adrian Klaver
adrian.klaver@aklaver.com






^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: Empty materialized view
@ 2024-03-24 20:36  Thiemo Kellner <thiemo@gelassene-pferde.biz>
  parent: Adrian Klaver <adrian.klaver@aklaver.com>
  0 siblings, 1 reply; 12+ messages in thread

From: Thiemo Kellner @ 2024-03-24 20:36 UTC (permalink / raw)
  To: Adrian Klaver <adrian.klaver@aklaver.com>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

Am 24.03.2024 um 21:30 schrieb Adrian Klaver:
> On 3/24/24 13:11, Thiemo Kellner wrote:
> Confirmed in the same session that created it or in a different session?

Different session, not knowing what that mattered.

Excerpt of the installation protocol:
…
## tenth level ##
Set materialised view QUERY_PER_TASK⠒MV up
psql:views/QUERY_PER_TASK⠒MV.pg_sql:3: HINWEIS:  materialisierte Sicht 
»query_per_task⠒mv« existiert nicht, wird übersprungen
DROP MATERIALIZED VIEW
SELECT 0
REFRESH MATERIALIZED VIEW
COMMENT
COMMIT
# insert data #
…

Check was done by DbVisualizer.

I was not able to create a test case. I tried

drop table if exists TEST_T cascade;
create table TEST_T (ID smallint);
insert into TEST_T (ID) values (1);
commit;

drop materialized view if exists TEST_MV_ON_TABLE;
create materialized view TEST_MV_ON_TABLE as select * from TEST_T with 
data; -- on table
commit;

select * from TEST_MV_ON_TABLE;

commit;
create or replace view VIEW_LEVEL_1 as select * from TEST_T;
create or replace view VIEW_LEVEL_2 as select v.id from VIEW_LEVEL_1 v 
cross join TEST_T;
create or replace view VIEW_LEVEL_3 as select v.id from VIEW_LEVEL_2 v 
cross join VIEW_LEVEL_1;
create or replace view VIEW_LEVEL_4 as select v.id from VIEW_LEVEL_3 v 
cross join VIEW_LEVEL_2;
create or replace view VIEW_LEVEL_5 as select v.id from VIEW_LEVEL_4 v 
cross join VIEW_LEVEL_3;
create or replace view VIEW_LEVEL_6 as select v.id from VIEW_LEVEL_5 v 
cross join VIEW_LEVEL_4;
create or replace view VIEW_LEVEL_7 as select v.id from VIEW_LEVEL_6 v 
cross join VIEW_LEVEL_5;
create or replace view VIEW_LEVEL_8 as select v.id from VIEW_LEVEL_7 v 
cross join VIEW_LEVEL_6;
create or replace view VIEW_LEVEL_9 as select v.id from VIEW_LEVEL_8 v 
cross join VIEW_LEVEL_7;
create or replace view VIEW_LEVEL_10 as select v.id from VIEW_LEVEL_9 v 
cross join VIEW_LEVEL_8;
commit;

drop materialized view if exists TEST_MV_ON_VIEWS;
create materialized view TEST_MV_ON_VIEWS as select * from VIEW_LEVEL_10 
with data; -- on views
commit;

select * from TEST_MV_ON_VIEWS;



But this works as expected.

Ok, I just added the following to my install script and there the data 
is visible.

select count(*) from SNOWRUNNER.TASK_DEPENDENCY⠒V;








^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: Empty materialized view
@ 2024-03-24 20:50  Adrian Klaver <adrian.klaver@aklaver.com>
  parent: Thiemo Kellner <thiemo@gelassene-pferde.biz>
  0 siblings, 1 reply; 12+ messages in thread

From: Adrian Klaver @ 2024-03-24 20:50 UTC (permalink / raw)
  To: Thiemo Kellner <thiemo@gelassene-pferde.biz>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

On 3/24/24 13:36, Thiemo Kellner wrote:
> Am 24.03.2024 um 21:30 schrieb Adrian Klaver:
>> On 3/24/24 13:11, Thiemo Kellner wrote:
>> Confirmed in the same session that created it or in a different session?
> 
> Different session, not knowing what that mattered

It does depending on the order of viewing. Namely if you viewed the 
'old' empty MV in the outside session before you dropped/created the 
'new' MV and committed the changes.

> 
> Excerpt of the installation protocol:
> …
> ## tenth level ##
> Set materialised view QUERY_PER_TASK⠒MV up
> psql:views/QUERY_PER_TASK⠒MV.pg_sql:3: HINWEIS:  materialisierte Sicht 
> »query_per_task⠒mv« existiert nicht, wird übersprungen
> DROP MATERIALIZED VIEW
> SELECT 0
> REFRESH MATERIALIZED VIEW
> COMMENT
> COMMIT
> # insert data #
> …
> 


> select count(*) from SNOWRUNNER.TASK_DEPENDENCY⠒V;

That is not the view you showed in your attached SQL in your previous 
post nor what is mentioned above. Also if I am following your naming 
scheme it is a regular view not a materialized view.

> 
> 
> 

-- 
Adrian Klaver
adrian.klaver@aklaver.com






^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: Empty materialized view
@ 2024-03-24 20:58  Thiemo Kellner <thiemo@gelassene-pferde.biz>
  parent: Adrian Klaver <adrian.klaver@aklaver.com>
  0 siblings, 1 reply; 12+ messages in thread

From: Thiemo Kellner @ 2024-03-24 20:58 UTC (permalink / raw)
  To: Adrian Klaver <adrian.klaver@aklaver.com>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

Am 24.03.2024 um 21:50 schrieb Adrian Klaver:
> On 3/24/24 13:36, Thiemo Kellner wrote:
> It does depending on the order of viewing. Namely if you viewed the 
> 'old' empty MV in the outside session before you dropped/created the 
> 'new' MV and committed the changes.

Something like the viewing session is in a transaction before the 
(re-)creation of the mv?

The view session is on auto commit. (It's sole purpose to query stuff 
and not to have explicitly terminate transactions do to syntax errors 
and so on.)

>>
>> Excerpt of the installation protocol:
>> …
>> ## tenth level ##
>> Set materialised view QUERY_PER_TASK⠒MV up
>> psql:views/QUERY_PER_TASK⠒MV.pg_sql:3: HINWEIS:  materialisierte Sicht 
>> »query_per_task⠒mv« existiert nicht, wird übersprungen
>> DROP MATERIALIZED VIEW
>> SELECT 0
>> REFRESH MATERIALIZED VIEW
>> COMMENT
>> COMMIT
>> # insert data #
>> …
>>
> 
> 
>> select count(*) from SNOWRUNNER.TASK_DEPENDENCY⠒V;
> 
> That is not the view you showed in your attached SQL in your previous 
> post nor what is mentioned above. Also if I am following your naming 
> scheme it is a regular view not a materialized view.

Feeling quite dumb now. But then, there neither is data visible in the 
install session.

insert data into TASK_DEPENDENCY⠒V
INSERT 0 34
COMMIT
  count
-------
      0
(1 row)


Thanks for taking care.





^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: Empty materialized view
@ 2024-03-24 21:06  Adrian Klaver <adrian.klaver@aklaver.com>
  parent: Thiemo Kellner <thiemo@gelassene-pferde.biz>
  0 siblings, 1 reply; 12+ messages in thread

From: Adrian Klaver @ 2024-03-24 21:06 UTC (permalink / raw)
  To: Thiemo Kellner <thiemo@gelassene-pferde.biz>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

On 3/24/24 13:58, Thiemo Kellner wrote:
> Am 24.03.2024 um 21:50 schrieb Adrian Klaver:
>> On 3/24/24 13:36, Thiemo Kellner wrote:
>> It does depending on the order of viewing. Namely if you viewed the 
>> 'old' empty MV in the outside session before you dropped/created the 
>> 'new' MV and committed the changes.
> 
> Something like the viewing session is in a transaction before the 
> (re-)creation of the mv?
> 
> The view session is on auto commit. (It's sole purpose to query stuff 
> and not to have explicitly terminate transactions do to syntax errors 
> and so on.)

Autocommit will only affect actions in that session, it will not make 
the other sessions actions visible. That depends on the other sessions 
committing actions.

See:

https://www.postgresql.org/docs/current/transaction-iso.html


> 
> Feeling quite dumb now. But then, there neither is data visible in the 
> install session.
> 
> insert data into TASK_DEPENDENCY⠒V
> INSERT 0 34

The above says the data was inserted.

> COMMIT
>   count
> -------
>       0


Where and when was the count query run?

> (1 row)
> 
> 
> Thanks for taking care.

-- 
Adrian Klaver
adrian.klaver@aklaver.com






^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: Empty materialized view
@ 2024-03-24 21:27  Thiemo Kellner <thiemo@gelassene-pferde.biz>
  parent: Adrian Klaver <adrian.klaver@aklaver.com>
  0 siblings, 1 reply; 12+ messages in thread

From: Thiemo Kellner @ 2024-03-24 21:27 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

Am 24.03.2024 um 22:06 schrieb Adrian Klaver:
>> The view session is on auto commit. (It's sole purpose to query stuff 
>> and not to have explicitly terminate transactions do to syntax errors 
>> and so on.)
> 
> Autocommit will only affect actions in that session, it will not make 
> the other sessions actions visible. That depends on the other sessions 
> committing actions.
> 
> See:
> 
> https://www.postgresql.org/docs/current/transaction-iso.html

I am under the impression that (higher transaction number in my example 
means more recent transaction) if my autocommit session's last 
transaction is 1 (some select), then the install session installs the 
objects and data with a series of transactions (2 - 20), i.e. several 
commits, and I afterwards use the autocommit session to check on the 
content of the objects installed in transactions 2 to 20, I should see 
the data having a transaction in the autocommit > 20. It works like this 
at least for the tables. But not for this mv.

>>
>> Feeling quite dumb now. But then, there neither is data visible in the 
>> install session.
>>
>> insert data into TASK_DEPENDENCY⠒V
>> INSERT 0 34
> 
> The above says the data was inserted.

But not into the MV but into TASK_DEPENDENCY⠒V.

> Where and when was the count query run?

Excerpt of the install script

\echo ## tenth level ##
\ir views/QUERY_PER_TASK⠒MV.pg_sql


-- \echo # functions relying on other objects #


\echo # insert data #
\echo ## first level ##
\ir insert_data/CENTRICITY.pg_sql
\ir insert_data/DIRECTION.pg_sql
\ir insert_data/GOOD_CLASS.pg_sql
\ir insert_data/NODE_TYPE.pg_sql
\ir insert_data/REGION.pg_sql
\ir insert_data/TASK_TYPE.pg_sql

\echo ## second level ##
\ir insert_data/AREA.pg_sql
\ir insert_data/DISTANCE⠒V.pg_sql
\ir insert_data/GOOD⠒V.pg_sql
\ir insert_data/MAP⠒V.pg_sql

\echo ## third level ##
\ir insert_data/DIRECT_NEIGHBOUR.pg_sql
\echo ### Scandinavia ###
\ir insert_data/Scandinavia/NODE⠒V.pg_sql
\ir insert_data/Scandinavia/PRODUCTION⠒V.pg_sql
\ir insert_data/Scandinavia/TASK⠒V.pg_sql

\echo ## forth level ##
\echo Scandinavia
\ir insert_data/Scandinavia/DROP_OFF⠒V.pg_sql
\ir insert_data/Scandinavia/PICK_UP⠒V.pg_sql
\ir insert_data/Scandinavia/TASK_DEPENDENCY⠒V.pg_sql

-- \echo ## fifth level ##
     -- \ir insert_data/Scandinavia/NODE_GOOD⠒V.pg_sql

select count(*) from SNOWRUNNER.TASK_DEPENDENCY⠒V;
select count(*) from SNOWRUNNER.QUERY_PER_TASK⠒MV;

commit;



Excerpt of the according protocol:

## tenth level ##
Set materialised view QUERY_PER_TASK⠒MV up
psql:views/QUERY_PER_TASK⠒MV.pg_sql:3: HINWEIS:  materialisierte Sicht 
»query_per_task⠒mv« existiert nicht, wird übersprungen
DROP MATERIALIZED VIEW
SELECT 0
REFRESH MATERIALIZED VIEW
COMMENT
COMMIT
# insert data #
## first level ##
insert data into CENTRICITY
INSERT 0 2
COMMIT
insert data into DIRECTION
INSERT 0 8
COMMIT
insert data into GOOD_CLASS
INSERT 0 15
COMMIT
insert data into NODE_TYPE
INSERT 0 3
COMMIT
insert data into REGION
INSERT 0 15
COMMIT
insert data into TASK_TYPE
INSERT 0 5
COMMIT
## second level ##
insert data into AREA
INSERT 0 16
COMMIT
insert data into DISTANCE⠒V
INSERT 0 3
COMMIT
insert data into GOOD⠒V
INSERT 0 164
COMMIT
insert data into MAP⠒V
INSERT 0 41
COMMIT
## third level ##
insert data into DIRECT_NEIGHBOUR
INSERT 0 8
INSERT 0 16
COMMIT
### Scandinavia ###
insert data into NODE⠒V
INSERT 0 112
COMMIT
insert data into PRODUCTION⠒V
INSERT 0 11
COMMIT
insert data into TASK⠒V
INSERT 0 56
COMMIT
## forth level ##
Scandinavia
insert data into DROP_OFF⠒V
INSERT 0 91
COMMIT
insert data into PICK_UP⠒V
INSERT 0 73
COMMIT
insert data into TASK_DEPENDENCY⠒V
INSERT 0 34
COMMIT
  count
-------
     66
(1 row)

  count
-------
      0
(1 row)

COMMIT






^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: Empty materialized view
@ 2024-03-25 00:24  Adrian Klaver <adrian.klaver@aklaver.com>
  parent: Thiemo Kellner <thiemo@gelassene-pferde.biz>
  0 siblings, 1 reply; 12+ messages in thread

From: Adrian Klaver @ 2024-03-25 00:24 UTC (permalink / raw)
  To: Thiemo Kellner <thiemo@gelassene-pferde.biz>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

On 3/24/24 14:27, Thiemo Kellner wrote:

>>> Feeling quite dumb now. But then, there neither is data visible in 
>>> the install session.
>>>
>>> insert data into TASK_DEPENDENCY⠒V
>>> INSERT 0 34
>>
>> The above says the data was inserted.
> 
> But not into the MV but into TASK_DEPENDENCY⠒V.
> 
>> Where and when was the count query run?
> 

> 
> Excerpt of the according protocol:
> 
> ## tenth level ##
> Set materialised view QUERY_PER_TASK⠒MV up
> psql:views/QUERY_PER_TASK⠒MV.pg_sql:3: HINWEIS:  materialisierte Sicht 
> »query_per_task⠒mv« existiert nicht, wird übersprungen
> DROP MATERIALIZED VIEW
> SELECT 0
> REFRESH MATERIALIZED VIEW
> COMMENT
> COMMIT

At above you have not entered the data into the tables the MV depends on 
so SELECT 0 is reasonable.

> # insert data #
> ## first level ##
> insert data into CENTRICITY
> INSERT 0 2
> COMMIT
> insert data into DIRECTION
> INSERT 0 8
> COMMIT
> insert data into GOOD_CLASS
> INSERT 0 15
> COMMIT
> insert data into NODE_TYPE
> INSERT 0 3
> COMMIT
> insert data into REGION
> INSERT 0 15
> COMMIT
> insert data into TASK_TYPE
> INSERT 0 5
> COMMIT
> ## second level ##
> insert data into AREA
> INSERT 0 16
> COMMIT
> insert data into DISTANCE⠒V
> INSERT 0 3
> COMMIT
> insert data into GOOD⠒V
> INSERT 0 164
> COMMIT
> insert data into MAP⠒V
> INSERT 0 41
> COMMIT
> ## third level ##
> insert data into DIRECT_NEIGHBOUR
> INSERT 0 8
> INSERT 0 16
> COMMIT
> ### Scandinavia ###
> insert data into NODE⠒V
> INSERT 0 112
> COMMIT
> insert data into PRODUCTION⠒V
> INSERT 0 11
> COMMIT
> insert data into TASK⠒V
> INSERT 0 56
> COMMIT
> ## forth level ##
> Scandinavia
> insert data into DROP_OFF⠒V
> INSERT 0 91
> COMMIT
> insert data into PICK_UP⠒V
> INSERT 0 73
> COMMIT
> insert data into TASK_DEPENDENCY⠒V
> INSERT 0 34
> COMMIT
>   count
> -------
>      66
> (1 row)
> 
>   count
> -------
>       0
> (1 row)

The 0 count above represents the below correct? :

select count(*) from SNOWRUNNER.QUERY_PER_TASK⠒MV;

If so, again that is reasonable as I don't see anywhere you refresh 
QUERY_PER_TASK⠒MV after the underlying tables have data entered. At this 
point it is still at the state you left it at here:

## tenth level ##
Set materialised view QUERY_PER_TASK⠒MV up
psql:views/QUERY_PER_TASK⠒MV.pg_sql:3: HINWEIS:  materialisierte Sicht 
»query_per_task⠒mv« existiert nicht, wird übersprungen
DROP MATERIALIZED VIEW
SELECT 0
REFRESH MATERIALIZED VIEW
COMMENT
COMMIT

> 
> COMMIT
> 
> 
> 

-- 
Adrian Klaver
adrian.klaver@aklaver.com






^ permalink  raw  reply  [nested|flat] 12+ messages in thread

* Re: Empty materialized view
@ 2024-03-25 09:41  Thiemo Kellner <thiemo@gelassene-pferde.biz>
  parent: Adrian Klaver <adrian.klaver@aklaver.com>
  0 siblings, 0 replies; 12+ messages in thread

From: Thiemo Kellner @ 2024-03-25 09:41 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

My bad as always. Having the refresh after the filling of the tables 
does the trick. Thanks for your help.





^ permalink  raw  reply  [nested|flat] 12+ messages in thread


end of thread, other threads:[~2024-03-25 09:41 UTC | newest]

Thread overview: 12+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-03-24 18:12 Empty materialized view Thiemo Kellner <thiemo@gelassene-pferde.biz>
2024-03-24 19:56 ` Erik Wienhold <ewie@ewie.name>
2024-03-24 20:11   ` Thiemo Kellner <thiemo@gelassene-pferde.biz>
2024-03-24 20:30     ` Adrian Klaver <adrian.klaver@aklaver.com>
2024-03-24 20:36       ` Thiemo Kellner <thiemo@gelassene-pferde.biz>
2024-03-24 20:50         ` Adrian Klaver <adrian.klaver@aklaver.com>
2024-03-24 20:58           ` Thiemo Kellner <thiemo@gelassene-pferde.biz>
2024-03-24 21:06             ` Adrian Klaver <adrian.klaver@aklaver.com>
2024-03-24 21:27               ` Thiemo Kellner <thiemo@gelassene-pferde.biz>
2024-03-25 00:24                 ` Adrian Klaver <adrian.klaver@aklaver.com>
2024-03-25 09:41                   ` Thiemo Kellner <thiemo@gelassene-pferde.biz>
2024-03-24 20:07 ` Adrian Klaver <adrian.klaver@aklaver.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox