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

Investigate wrong query #1 #1531

Closed
aminlatifi opened this issue May 6, 2024 · 12 comments
Closed

Investigate wrong query #1 #1531

aminlatifi opened this issue May 6, 2024 · 12 comments
Assignees

Comments

@aminlatifi
Copy link
Member

aminlatifi commented May 6, 2024

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 aminlatifi added the p0 label May 6, 2024
@aminlatifi aminlatifi assigned jainkrati and aminlatifi and unassigned jainkrati May 6, 2024
@jainkrati
Copy link
Collaborator

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
Copy link
Collaborator

@RamRamez can you pls take this up

@RamRamez
Copy link
Collaborator

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

@aminlatifi
Copy link
Member Author

@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

This comment was marked as duplicate.

@divine-comedian
Copy link
Collaborator

@RamRamez - What is the update on this issue?

@RamRamez
Copy link
Collaborator

RamRamez commented May 15, 2024

@RamRamez - What is the update on this issue?

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

@RamRamez
Copy link
Collaborator

@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

@maryjaf
Copy link
Collaborator

maryjaf commented May 20, 2024

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

#825 (comment)
#825 (comment)

@divine-comedian
Copy link
Collaborator

@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?

@RamRamez
Copy link
Collaborator

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

@jainkrati
Copy link
Collaborator

@divine-comedian @maryjaf can we close this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants