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

database info collection query does not complete (timeout) #41

Open
genez opened this issue May 7, 2021 · 0 comments
Open

database info collection query does not complete (timeout) #41

genez opened this issue May 7, 2021 · 0 comments
Assignees

Comments

@genez
Copy link

genez commented May 7, 2021

Hello, I am trying to map a third-party postres 9.5 database with more than 22000 (yes, twenty-two thousands) tables.
My goal is to fetch some data in my Go application.
Obviously I am interested in a couple of tables, the command line I am using is this:

genna model-named -c postgres://postgres:postgres@hostname/database?sslmode=disable -t hrdd_001employee00,hrdd_001employee02,hrdd_001employee11,codd_001subject03_m,codd_001subject04 -o models.go

Unfortunately the command never finishes processing.
So I debugged the application and found that the query that is taking forever is at dizzyfool/genna/lib/store.go@180

In particular, the offending subquery is

select distinct
				 	kcu.table_schema as table_schema,
					kcu.table_name   as table_name,
					kcu.column_name  as column_name,
					array_agg((
						select constraint_type::text 
						from information_schema.table_constraints tc 
						where tc.constraint_name = kcu.constraint_name 
							and tc.constraint_schema = kcu.constraint_schema 
							and tc.constraint_catalog = kcu.constraint_catalog
						limit 1
					)) as constraint_types
				from information_schema.key_column_usage kcu
				group by kcu.table_schema, kcu.table_name, kcu.column_name

If I execute this statement on my database, this query never finishes
If I add a where condition with table names filter, it is very slow but it completes.

What do you think about this change?

@dizzyfool dizzyfool self-assigned this Jun 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants