Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: implement pg_stat tables where possible #70781

Open
rafiss opened this issue Sep 27, 2021 · 1 comment
Open

sql: implement pg_stat tables where possible #70781

rafiss opened this issue Sep 27, 2021 · 1 comment
Labels
A-tools-aws-dms Blocking support for AWS Database Migration Service C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)

Comments

@rafiss
Copy link
Collaborator

rafiss commented Sep 27, 2021

Add implementations for the following tables, for the columns that can be supported in CockroachDB

  • pg_statistic
  • pg_statistic_ext_data
  • pg_stats
  • pg_stats_ext

Jira issue: CRDB-10219

@rafiss rafiss added the C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) label Sep 27, 2021
@rafiss rafiss added this to Triage in SQL Sessions - Deprecated via automation Sep 27, 2021
@blathers-crl blathers-crl bot added the T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) label Sep 27, 2021
@rafiss rafiss moved this from Triage to PG compat candidates in SQL Sessions - Deprecated Sep 27, 2021
@otan
Copy link
Contributor

otan commented Feb 21, 2023

reltuples in pg_class has a similar affliction. this prevent AWS DMS from providing "estimates" of progress.

example query:

2022-12-08 19:04:34 UTC:172.31.55.39(37296):postgres@replicationload:[666]:LOG:  statement: BEGIN;declare "SQL_CUR0x146ee0196860" cursor with hold for 
	 ( 
	  select
	     t.schemaname                  as ownerName,
	     t.tablename                   as tableName,
	     /*c.oid*/ cast(c.oid as bigint) as objectId, 
	     (select n_live_tup from pg_stat_user_tables s where s.schemaname=t.schemaname and s.relname=t.tablename)  as row_count,
		   1						as tableType
	  from pg_tables t, pg_class c, pg_namespace n
	  /*where clause number 1 (table where clause)*/
	  where t.tablename=c.relname
	  and   n.oid	   = c.relnamespace
	  and   t.schemaname = n.nspname
	  and t.schemaname <> 'information_schema'
	  and t.tablename  <> 'awsdms_ddl_audit'
	  and t.tablename  <> 'awsdms_heartbeat'
	  and
	  (
	     (( (1=0) ) -- Explicit Inclusion
	     or 
	     (
	        ( 
	 t.schemaname LIKE '%' and t.schemaname not like 'pg\_%' and t.tablename LIKE 'good\_table'
	 ) -- Patterned Inclusion
	          and not
	        ( 
	 t.schemaname LIKE '%' and t.schemaname not like 'pg\_%' and t.tablename LIKE 'awsdms\_changes%'
	 or 
	 t.schemaname LIKE '%' and t.schemaname not like 'pg\_%' and t.tablename LIKE 'awsdms\_apply%'
	 or 
	 t.schemaname LIKE '%' and t.schemaname not like 'pg\_%' and t.tablename LIKE 'awsdms\_truncation%'
	 or 
	 t.schemaname LIKE '%' and t.schemaname not like 'pg\_%' and t.tablename LIKE 'awsdms\_audit\_table'
	 or 
	 t.schemaname LIKE '%' and t.schemaname not like 'pg\_%' and t.tablename LIKE 'awsdms\_status'
	 or 
	 t.schemaname LIKE '%' and t.schemaname not like 'pg\_%' and t.tablename LIKE 'awsdms\_suspended\_tables'
	 or 
	 t.schemaname LIKE '%' and t.schemaname not like 'pg\_%' and t.tablename LIKE 'awsdms\_history'
	 or 
	 t.schemaname LIKE '%' and t.schemaname not like 'pg\_%' and t.tablename LIKE 'awsdms\_validation\_failure'
	 or 
	 t.schemaname LIKE '%' and t.schemaname not like 'pg\_%' and t.tablename LIKE 'awsdms\_cdc\_%awsdms\_full\_load\_exceptions%'
	 ) -- Patterned exclusion
	      ))
	      and 
	      (1=1) 
	  )
	
	  UNION
	
	  select
	     v.schemaname                  as ownerName,
	     v.viewname                   as tableName,
	     /*c.oid*/ cast(c.oid as bigint) as objectId, 
	     0  as row_count,/**/ 
		   2						as tableType
	  from pg_views v, pg_class c, pg_namespace n
	  /*where clause number 2 (view where clause)*/ 
	  where v.viewname = c.relname
	  and   n.oid	    = c.relnamespace
	  and   v.schemaname = n.nspname
	  and v.schemaname <> 'information_schema'
	  and v.viewname  <> 'awsdms_ddl_audit'
	  and v.viewname  <> 'awsdms_heartbeat'
	  and
	  (
	     (( (1=0) ) -- Explicit Inclusion
	     or 
	     (
	        ( (1=0) ) -- Patterned Inclusion
	          and not
	        ( (1=0) ) -- Patterned exclusion
	      ))
	      and 
	      (1=1) 
	  )
	 )
	 order by 1,2
	;fetch 10000 in "SQL_CUR0x146ee0196860"

@otan otan added the A-tools-aws-dms Blocking support for AWS Database Migration Service label Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tools-aws-dms Blocking support for AWS Database Migration Service C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)
Projects
No open projects
SQL Sessions - Deprecated
PG compat candidates
Development

No branches or pull requests

3 participants