Hi not sure if this is the right channel to ask th...
# gooddata-platform
c
Hi not sure if this is the right channel to ask this. we are having some issues with some visuals on our dashboards sometimes taking up to a minute to load. We are using Direct Query on our reports so we were wondering, Does each visual load all the data it requires or does GoodData load all the data on the data model then run the visuals from that? Thanks
🚀 1
j
Hi Chris, GoodData loads the data specifically for that viz when querying the database. It does not load data for the whole model and then load the visuals on the dashboard.
I believe you are actually working with GoodData cloud and not the platform version of the product. Therefore, you may find some tips on optimization here: https://www.gooddata.com/docs/cloud/connect-data/performance/
c
Thanks, yeah we are looking at some of those options - indexing helped but some visuals are still struggling
j
How much data is being loaded into those viz and how many filters are being used?
c
We have narrowed the issue down into a problem with the previous period being calculated. I believe our data guy is going to post about it today
j
Ok, if he could continue in this thread it would be very helpful on our side.
c
@Tj Wood @Hayley
t
Good Morning @Joseph Heun, As previously stated by @Chris Potts, the issue regarding our visualisation's speed issues appears to be a generic issue within the previous period section of the sql query that GoodData generates on behalf of the visualisation. For Example.
Copy code
SELECT CASE 
		WHEN COALESCE("t2"."def_m_0881e06adc02c444b9a435e7abd3ed8d", FALSE)
			THEN "t2"."m_0881e06adc02c444b9a435e7abd3ed8d"
		ELSE NULL
		END AS "m_1",
	CASE 
		WHEN COALESCE("t6"."def_m_2e91a40b57e4e88d8a59f1340b416d30", FALSE)
			THEN "t6"."m_2e91a40b57e4e88d8a59f1340b416d30"
		ELSE NULL
		END AS "m_2"
FROM (
	SELECT AVG("AR_SalesInvoices"."Total Net") AS "m_0881e06adc02c444b9a435e7abd3ed8d",
		TRUE AS "def_m_0881e06adc02c444b9a435e7abd3ed8d"
	FROM "autoflow_dev"."AR_SalesInvoices"
	INNER JOIN "autoflow_dev"."AR_JobControl" ON "AR_SalesInvoices"."jobid" = "AR_JobControl"."jobid"
		AND "AR_SalesInvoices"."sitecd" = "AR_JobControl"."sitecd"
	WHERE "AR_JobControl"."Invoiced Date" >= CAST(TO_TIMESTAMP('2025-5', 'YYYY-MM') AS TIMESTAMP)
		AND "AR_JobControl"."Invoiced Date" < (CAST(TO_TIMESTAMP('2025-5', 'YYYY-MM') AS TIMESTAMP) + (INTERVAL '1 month'))
		AND "AR_SalesInvoices"."Labour Net" <> 0
		AND "AR_JobControl"."Job Status" NOT IN (
			'CANCELLED',
			'WRITE-OFF'
			)
		AND (
			"AR_JobControl"."Vehicle WriteOff" IS NULL
			OR "AR_JobControl"."Vehicle WriteOff" <> 'Yes'
			)
	GROUP BY CAST(NULL AS INTEGER)
	) AS "t2"
FULL JOIN (
	SELECT AVG("AR_SalesInvoices0"."Total Net") AS "m_2e91a40b57e4e88d8a59f1340b416d30",
		TRUE AS "def_m_2e91a40b57e4e88d8a59f1340b416d30"
	FROM "autoflow_dev"."AR_SalesInvoices" AS "AR_SalesInvoices0"
	INNER JOIN "autoflow_dev"."AR_JobControl" AS "AR_JobControl0" ON "AR_SalesInvoices0"."jobid" = "AR_JobControl0"."jobid"
		AND "AR_SalesInvoices0"."sitecd" = "AR_JobControl0"."sitecd"
	WHERE "AR_JobControl0"."Invoiced Date" >= (CAST(TO_TIMESTAMP('2025-5', 'YYYY-MM') AS TIMESTAMP) + (INTERVAL '-1 month'))
		AND (
			"AR_JobControl0"."Invoiced Date" = (("AR_JobControl0"."Invoiced Date" + (INTERVAL '-1 month')) + (INTERVAL '1 month'))
			AND "AR_JobControl0"."Invoiced Date" < ((CAST(TO_TIMESTAMP('2025-5', 'YYYY-MM') AS TIMESTAMP) + (INTERVAL '-1 month')) + (INTERVAL '1 month'))
			)
		AND (
			"AR_JobControl0"."Vehicle WriteOff" <> 'Yes'
			AND (
				"AR_JobControl0"."Job Status" NOT IN (
					'CANCELLED',
					'WRITE-OFF'
					)
				AND "AR_SalesInvoices0"."Labour Net" <> 0
				)
			)
	GROUP BY CAST(NULL AS INTEGER)
	) AS "t6" ON TRUE
WHERE COALESCE("t2"."def_m_0881e06adc02c444b9a435e7abd3ed8d", FALSE)
	OR COALESCE("t6"."def_m_2e91a40b57e4e88d8a59f1340b416d30", FALSE);
This is the query generated by gooddata that takes 8 minutes to run. The issue appears to be with this section of the previous period join -
Copy code
"AR_JobControl0"."Invoiced Date" = (("AR_JobControl0"."Invoiced Date" + (INTERVAL '-1 month')) + (INTERVAL '1 month'))
Which doesn't seem to be relevant in calculating the previous period date range. If you take this section out - the query runs within 1.2 seconds.
Copy code
SELECT CASE 
		WHEN COALESCE("t2"."def_m_0881e06adc02c444b9a435e7abd3ed8d", FALSE)
			THEN "t2"."m_0881e06adc02c444b9a435e7abd3ed8d"
		ELSE NULL
		END AS "m_1",
	CASE 
		WHEN COALESCE("t6"."def_m_2e91a40b57e4e88d8a59f1340b416d30", FALSE)
			THEN "t6"."m_2e91a40b57e4e88d8a59f1340b416d30"
		ELSE NULL
		END AS "m_2"
FROM (
	SELECT AVG("AR_SalesInvoices"."Total Net") AS "m_0881e06adc02c444b9a435e7abd3ed8d",
		TRUE AS "def_m_0881e06adc02c444b9a435e7abd3ed8d"
	FROM "autoflow_dev"."AR_SalesInvoices"
	INNER JOIN "autoflow_dev"."AR_JobControl" ON "AR_SalesInvoices"."jobid" = "AR_JobControl"."jobid"
		AND "AR_SalesInvoices"."sitecd" = "AR_JobControl"."sitecd"
	WHERE "AR_JobControl"."Invoiced Date" >= CAST(TO_TIMESTAMP('2025-5', 'YYYY-MM') AS TIMESTAMP)
		AND "AR_JobControl"."Invoiced Date" < (CAST(TO_TIMESTAMP('2025-5', 'YYYY-MM') AS TIMESTAMP) + (INTERVAL '1 month'))
		AND "AR_SalesInvoices"."Labour Net" <> 0
		AND "AR_JobControl"."Job Status" NOT IN (
			'CANCELLED',
			'WRITE-OFF'
			)
		AND (
			"AR_JobControl"."Vehicle WriteOff" IS NULL
			OR "AR_JobControl"."Vehicle WriteOff" <> 'Yes'
			)
	GROUP BY CAST(NULL AS INTEGER)
	) AS "t2"
FULL JOIN (
	SELECT AVG("AR_SalesInvoices0"."Total Net") AS "m_2e91a40b57e4e88d8a59f1340b416d30",
		TRUE AS "def_m_2e91a40b57e4e88d8a59f1340b416d30"
	FROM "autoflow_dev"."AR_SalesInvoices" AS "AR_SalesInvoices0"
	INNER JOIN "autoflow_dev"."AR_JobControl" AS "AR_JobControl0" ON "AR_SalesInvoices0"."jobid" = "AR_JobControl0"."jobid"
		AND "AR_SalesInvoices0"."sitecd" = "AR_JobControl0"."sitecd"
	WHERE "AR_JobControl0"."Invoiced Date" >= (CAST(TO_TIMESTAMP('2025-5', 'YYYY-MM') AS TIMESTAMP) + (INTERVAL '-1 month'))
		AND ("AR_JobControl0"."Invoiced Date" < ((CAST(TO_TIMESTAMP('2025-5', 'YYYY-MM') AS TIMESTAMP) + (INTERVAL '-1 month')) + (INTERVAL '1 month'))
			)
		AND (
			"AR_JobControl0"."Vehicle WriteOff" <> 'Yes'
			AND (
				"AR_JobControl0"."Job Status" NOT IN (
					'CANCELLED',
					'WRITE-OFF'
					)
				AND "AR_SalesInvoices0"."Labour Net" <> 0
				)
			)
	GROUP BY CAST(NULL AS INTEGER)
	) AS "t6" ON TRUE
WHERE COALESCE("t2"."def_m_0881e06adc02c444b9a435e7abd3ed8d", FALSE)
	OR COALESCE("t6"."def_m_2e91a40b57e4e88d8a59f1340b416d30", FALSE);
This redundant section of code appears within each visualisation that utilises your "Previous Period" feature and causes speed issues in all of them when the period is greater than "This Week". Removing the previous period feature from the affected visualisations returns the data instantly. @Hayley
j
Hi Tim, Thank you so much for the details here. I'm going to open a ticket with our support team on this and will loop all of you into it. We will need to investigate the behavior within the LDM/org, so when I reach out to you in the ticket please provide a direct link to the viz itself.