Start a new topic

postgresql 10 beta - partition table

PostgreSQL version 10(beta) supports partitioned tables.

Table attribute 'p' has been added.

The parent table is not visible.


so.


It works after modifying as below.

      <Command id="postgresql8.getTables">
         <SQL>
            <![CDATA[
SELECT c.relname                                     AS "Name",
       n.nspname                                     AS "Schema",
       pg_get_userbyid(c.relowner)                   AS "Owner",
       t.spcname                                     AS "Tablespace",
       c.relhasindex                                 AS "Has Indexes",
       c.relhasrules                                 AS "Has Rules",
       ]]>
            <If test="#util.isDatabaseVersionGTE(8,4)">
               <![CDATA[
       c.relhastriggers                               AS "Has Triggers",
       ]]>
            </If>
            <Else>
               <![CDATA[
       (c.reltriggers > 0)                            AS "Has Triggers",
       ]]>
            </Else>
            <![CDATA[
       c.relisshared                                 AS "Is Shared",
       c.relnatts                                    AS "N Cols",
       pg_catalog.obj_description(c.oid, 'pg_class') AS "Comment"
FROM   pg_class c
   LEFT JOIN pg_namespace n   ON n.oid = c.relnamespace
   LEFT JOIN pg_tablespace t  ON t.oid = c.reltablespace
WHERE 1=1 
]]>
<If test="#util.isDatabaseVersionGTE(10,0)">
AND c.relkind in( 'r'::"char", 'p'::"char")
</If>
 <Else>
AND c.relkind in( 'r'::"char")
 </Else>
<![CDATA[
AND   n.nspname LIKE '${schema}'
AND   c.relname LIKE '${table}'
ORDER BY n.nspname, c.relname
            ]]>
         </SQL>
      </Command>

 


Hi Roger,


thank you very much!


Regards

Wolfgang

Wolfgang,


Just to inform you that the just released DbVisualizer 10.0.14 now fixes this that you reported a while ago:


- if you click on the partitioned table in the navigator, you can see the columns of the table in a tree view.

  But when you open this table in the database window (the big window on the right side), the "Columns"

  tab does not show the columns. No big deal, but this seems to be wrong ...


Regards


Roger

Hi Wolfgang,


I finally had some time to look at this. There seems to be some configuration issues, because in your installation, a profile named /opt/DbVisualizer/resources/profiles/postgresql.xml is used, when it instead should use one named /opt/DbVisualizer/resources/profiles/postgresql8.xml (the difference being the "8" in the filename). The one that gets used in your case is a very limited one that is intended for PostgreSQL versions older than version 8. Have you manually changed anything in your DbVisualizer installation? Which installer did you use when you installed DbVisualizer 10.0.8?


The choice of profile is based in the database version returned by the JDBC driver. I see another oddity in your log that indicates that you may have the wrong driver installed, namely that it throws a java.sql.SQLFeatureNotSupportedException for the Statement#getLargeUpdateCount() method. The driver bundled with DbVisualizer does not do this. Have you replaced the driver that comes bundled with DbVisualizer?


If none of this sounds familiar, I suggest that you uninstall DbVisualizer and reinstall the latest version (10.0.10). It is important that you first uninstall the current version, to get rid of potentially old files that have not been replaced when upgrading. Reinstalling DbVisualizer does not affect any user settings.


Best Regards,

Hans

Hi Wolfgang,


I will look into this but I take your advice and leave it for later.


Best Regards,

Hans

 Hi Hans,


I have produced the debug log you wanted. See attachment.

The log protocols the following actions:

- connect to the database

- open the database navigation item (AMK173 in this case)

- open the "TABLES" item


But do not waste too much time on this - it's not urgent :)


Best regards

Wolfgang

log

Hi Wolfgang,


Strange. I'm still not able to reproduce this. I have tested creating the table and partitions both with postgres as the owner and with my test schema as the owner. In both cases, I see the table under the Tables nodes and its partitions under the Partitions node. My test schema, corresponding to your "ask_schema" is named "test" and I have also used this GRANT statement if that makes a difference:


grant all privileges on schema test to test


Please open Tools->Debug Window and enable debugging for DbVisualizer. Click on the garbage can button to remove old output. Then perform this operation again and include the debug output in your reply. 


I did find another bug, namely that the database qualifier in the DDL for the partitions is incorrectly set to the owner instead of the database. This will be fixed in the next maintenance release.


Best Regards,

Hans

Hi Hans,

here is how I reproduce the second problem:

CREATE TABLE amk_schema.measurement (
    city_id         int not null,
    logdate         date not null,
    peaktemp        int,
    unitsales       int
) PARTITION BY RANGE (logdate);

CREATE TABLE amk_schema.measurement_01 PARTITION OF amk_schema.measurement
    FOR VALUES FROM ('2017-01-01') TO ('2018-01-01');
   
CREATE TABLE amk_schema.measurement_00 PARTITION OF amk_schema.measurement
    FOR VALUES FROM ('2016-01-01') TO ('2017-01-01');
   
insert into amk_schema.measurement (city_id, logdate, peaktemp, unitsales) values (17, '2017-05-04', 30, 100);


-- I even do that:
grant all on amk_schema.measurement to amk_schema;
grant all on amk_schema.measurement_01 to amk_schema;
grant all on amk_schema.measurement_00 to amk_schema;


After all, I am happy when I open the database as user "postgres", but when I open it as "amk_schema"

I only see the partitions "measurement_00" and "measurement_01" in the navigation pane. But not the

parent table "measurement".


Best regards,

Wolfgang

Hi Wolfgang,


The issue with the empty Columns tab is due to the bundled JDBC driver version. It is fixed in the latest version, 42.2.1, available here:


https://jdbc.postgresql.org/download.html


We will look into bundling the latest driver version with the next maintenance release. If you want to upgrade now, create a new Driver Manager Entry for it e.g. named PostgreSQL 42.2.1 and select that driver for your connection, as described here:


http://confluence.dbvis.com/display/UG100/Installing+a+JDBC+Driver


I cannot reproduce the second issue as I said earlier so your input about what I may be missing is welcome.


Best Regards,

Hans

Hi Wolfgang,


I can reproduce the first issue, i.e. that the Columns tab is empty, and will look into that.


However, I'm not able to reproduce the second issue. I have a schema named "test" in a database named "postgres". I connect with a user named "test" and create a partitioned table. Looking at the Info tab for this table I see that it is owned by user "test" and is part of the "test" schema. It shows up in the Databases tree as a table and its Partitions node list the partitions. Am I doing something different than the case you describe?


Best Regards,

Hans

Hi Roger,

thank you! I just installed 10.0.8 and it really looks good!

I have seen only a few minor flaws:

- if you click on the partitioned table in the navigator, you can see the columns of the table in a tree view.

  But when you open this table in the database window (the big window on the right side), the "Columns"

  tab does not show the columns. No big deal, but this seems to be wrong ...

- I can see the new partition view only if I log in to the database as a superuser. If the partitioned table is

  owned by user "test_schema" and inside the schema "test_schema" and I log in as user "test_schema"

  then the partitions are shown as regular tables and the partitioned table (the master of the partitions) is

  missing at all.


Regards,

Wolfgang


Wolfgang,


DbVisualizer 10.0.7 is now released with extended support for partitioned tables.


Open Help->Check for Update in DbVisualizer to perform the upgrade. 

An alternative is that you download from our web site: 


Regards

Roger

Hi Wolfgang,


Thanks. We will look into it and let you know if we add more support for partitioned tables.


Best Regards,

Hans

Hi Hans,

I really would like to post a screenshot of how pgAdmin4 v.20 handles partitions,
but I do not know if this is legal :)
So here is what we would like to see: let table A be partitioned and B and C be partitions of A.
Then:
- only A shall be listed under "Tables", but B and C may *not*
- for A there is a navigation sub-item "Partitions", because A is partitioned
- Unfolding "Partitions" under the navigation item of A shall show B and C
  as partitions.
- for the partitioned table A you could show interesting things like number of partitions
- for the partitions B and C you could show at least the partition constraints
Furthermore imagine a partioning wizard that helps in creating non-overlapping partitions,
or an analyzer that checks if data are unevenly spread among the partitions ... just be
creative :)
Native Partitions is THE feature of PostgreSQL 10. Thus a good handling of partitions might
be the main thing Postgres 10 users expect from a db management tool.

Best regards
Wolfgang

 

Hi Wolfgang,


It would be great if you can briefly describe what features you would find helpful, so we can look into it. We made a small change a few versions back to list the partitioned tables along with regular tables, at the suggestion of another customer. I assume you would like to see them separated from regular tables with different actions and views?


Best Regards,

Hans

Postgres 10 now allows for native partitioning. We will use this feature within a project in a
big german company. Currently, dbvis 10.0.4 does not recognize a partitioned table and handles
partitions just like regular tables. Thus we currently recommed pgAdmin4 v2.0 which correctly
subsumes all partitions under its parent table and subpartions under their partition and so on.
Maybe you want to add some cool partition features to dbvisualizer :)

Best regards
Wolfgang
 

 

Login or Signup to post a comment