impact-graph icon indicating copy to clipboard operation
impact-graph copied to clipboard

Investigate wrong query #1

Open aminlatifi opened this issue 9 months ago • 1 comments

This query is taking a long time and it seems it was not well designed since it returns the same project data on each row with only different project addresses.

SELECT
	"project"."id" AS "project_id",
	"project"."title" AS "project_title",
	"project"."slug" AS "project_slug",
	"project"."slugHistory" AS "project_slugHistory",
	"project"."admin" AS "project_admin",
	"project"."description" AS "project_description",
	"project"."descriptionSummary" AS "project_descriptionSummary",
	"project"."traceCampaignId" AS "project_traceCampaignId",
	"project"."givingBlocksId" AS "project_givingBlocksId",
	"project"."changeId" AS "project_changeId",
	"project"."website" AS "project_website",
	"project"."youtube" AS "project_youtube",
	"project"."creationDate" AS "project_creationDate",
	"project"."updatedAt" AS "project_updatedAt",
	"project"."organizationId" AS "project_organizationId",
	"project"."coOrdinates" AS "project_coOrdinates",
	"project"."image" AS "project_image",
	"project"."impactLocation" AS "project_impactLocation",
	"project"."balance" AS "project_balance",
	"project"."stripeAccountId" AS "project_stripeAccountId",
	"project"."walletAddress" AS "project_walletAddress",
	"project"."verified" AS "project_verified",
	"project"."verificationStatus" AS "project_verificationStatus",
	"project"."isImported" AS "project_isImported",
	"project"."giveBacks" AS "project_giveBacks",
	"project"."qualityScore" AS "project_qualityScore",
	"project"."contacts" AS "project_contacts",
	"project"."statusId" AS "project_statusId",
	"project"."adminUserId" AS "project_adminUserId",
	"project"."totalDonations" AS "project_totalDonations",
	"project"."totalTraceDonations" AS "project_totalTraceDonations",
	"project"."totalReactions" AS "project_totalReactions",
	"project"."totalProjectUpdates" AS "project_totalProjectUpdates",
	"project"."listed" AS "project_listed",
	"project"."reviewStatus" AS "project_reviewStatus",
	"addresses"."id" AS "addresses_id",
	"addresses"."title" AS "addresses_title",
	"addresses"."networkId" AS "addresses_networkId",
	"addresses"."chainType" AS "addresses_chainType",
	"addresses"."address" AS "addresses_address",
	"addresses"."projectId" AS "addresses_projectId",
	"addresses"."userId" AS "addresses_userId",
	"addresses"."isRecipient" AS "addresses_isRecipient",
	"addresses"."updatedAt" AS "addresses_updatedAt",
	"addresses"."createdAt" AS "addresses_createdAt",
	"categories"."id" AS "categories_id",
	"categories"."name" AS "categories_name",
	"categories"."value" AS "categories_value",
	"categories"."source" AS "categories_source",
	"categories"."isActive" AS "categories_isActive",
	"categories"."mainCategoryId" AS "categories_mainCategoryId"
FROM
	"public"."project" "project"
	LEFT JOIN "public"."project_address" "addresses" ON "addresses"."projectId" = "project"."id"
	INNER JOIN "public"."project_categories_category" "project_categories" ON "project_categories"."projectId" = "project"."id"
	INNER JOIN "public"."category" "categories" ON "categories"."id" = "project_categories"."categoryId"
	AND ("categories"."isActive" = true )
WHERE
	"project"."slug" = 'pcrf-palestine-childrens-relief-fund'
	OR 'pcrf-palestine-childrens-relief-fund' = ANY (PROJECT."slugHistory")

The answer:

image

aminlatifi avatar May 06 '24 08:05 aminlatifi

May be causing slowness; but Amin is not entirely sure. need to know how much improvement will we get if we take this up.

jainkrati avatar May 06 '24 13:05 jainkrati

@RamRamez can you pls take this up

jainkrati avatar May 08 '24 12:05 jainkrati

@aminlatifi can you please send me the file name containing this query? I couldn't find it.

RamRamez avatar May 12 '24 23:05 RamRamez

@aminlatifi can you please send me the file name containing this query? I couldn't find it.

It must be by high chance the query generated by the TypeOrm for fetch project by slug. It's not written explicitly by us (developers)

aminlatifi avatar May 13 '24 04:05 aminlatifi

@aminlatifi can you please send me the file name containing this query? I couldn't find it.

It must be by high chance the query generated by the TypeOrm for fetch project by slug. It's not written explicitly buy us (developers)

aminlatifi avatar May 13 '24 04:05 aminlatifi

@RamRamez - What is the update on this issue?

divine-comedian avatar May 15 '24 19:05 divine-comedian

@RamRamez - What is the update on this issue?

  • [x] Optimizing single project page query
  • [x] Optimizing donate project page query
  • [x] Optimizing create project success page query
  • [x] Optimizing verification form page query
  • [x] Adding lazy loading to projectBySlug resolver

RamRamez avatar May 15 '24 20:05 RamRamez

@maryjaf to test and verify Please test functionality of these pages:

  1. project creation success view
  2. single project view
  3. donate page
  4. verification flow

RamRamez avatar May 19 '24 15:05 RamRamez

Please test functionality of these pages:

  1. project creation success view
  2. single project view
  3. donate page
  4. verification flow

-I haven't seen problem in project creation success view, verification flow and donate page

but there is two problems in single project view that I've mentioned on # 823 @RamRamez

https://github.com/Giveth/impact-graph/issues/825#issuecomment-2119841319 https://github.com/Giveth/impact-graph/issues/825#issuecomment-2119886720

maryjaf avatar May 20 '24 09:05 maryjaf

@RamRamez are these issues that @maryjaf just reported related to the query changes you've done in this issue?

If they are no related let's move this issue to done?

divine-comedian avatar May 20 '24 13:05 divine-comedian

@divine-comedian I think we can assume this issue as done and track two problems Maryam reported in issue #825

RamRamez avatar May 20 '24 14:05 RamRamez

@divine-comedian @maryjaf can we close this?

jainkrati avatar May 29 '24 12:05 jainkrati