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

sc:countries performance issues. #1146

Open
sbrow opened this issue Aug 24, 2024 · 4 comments
Open

sc:countries performance issues. #1146

sbrow opened this issue Aug 24, 2024 · 4 comments

Comments

@sbrow
Copy link
Contributor

sbrow commented Aug 24, 2024

Description

I was looking into why my /checkout/information page took so long to load. It turns out that, according to the DebugBar, nearly 90% of the load time was spent rendering {{ sc:countries }} tags for the shipping and billing address. This takes over 5 seconds on my intel i7-1260P.

image

Steps to reproduce

  1. Clone the starter kit
  2. Turn on the debug bar
  3. add a product to the cart
  4. Continue checkout until the information page.
  5. View the load times

Environment

Environment
Application Name: <REDACTED>
Laravel Version: 11.20.0
PHP Version: 8.2.13
Composer Version: 2.6.5
Environment: local
Debug Mode: ENABLED
URL: <REDACTED>.test
Maintenance Mode: OFF
Timezone: America/New_York
Locale: en

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: null
Cache: file
Database: mysql
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Simple Commerce
Currencies: USD
Gateways: Stripe
Repository: Customer: DuncanMcClean\SimpleCommerce\Customers\UserCustomerRepository
Repository: Order: DuncanMcClean\SimpleCommerce\Orders\EntryOrderRepository
Repository: Product: DuncanMcClean\SimpleCommerce\Products\EntryProductRepository
Shipping Methods: Flat Rate Shipping, Free Shipping
Tax Engine: DuncanMcClean\SimpleCommerce\Tax\Standard\TaxEngine

Sentry
Enabled: MISSING DSN
Environment: local
Laravel SDK Version: 4.5.1
PHP SDK Version: 4.7.0
Release: NOT SET
Sample Rate Errors: 100%
Sample Rate Performance Monitoring: 100%
Sample Rate Profiling: NOT SET
Send Default PII: DISABLED

Statamic
Addons: 8
Sites: 1
Stache Watcher: Enabled
Static Caching: Disabled
Version: 5.22.0 PRO

Statamic Addons
arthurperton/wordpress-users: 1.2.0
duncanmcclean/guest-entries: 4.0.1
duncanmcclean/simple-commerce: 7.4.2
<REDACTED>/sc-affiliates: dev-8121e749b3eef1457b7bede10f2ddec0254748b4
<REDACTED>/sc-checkout: dev-8121e749b3eef1457b7bede10f2ddec0254748b4
<REDACTED>/sc-subscriptions: dev-8121e749b3eef1457b7bede10f2ddec0254748b4
sbrow/banner: dev-8121e749b3eef1457b7bede10f2ddec0254748b4
statamic/seo-pro: 6.0.3

@sbrow sbrow added the bug label Aug 24, 2024
@duncanmcclean
Copy link
Owner

Simple Commerce's Country field is being replaced by Statamic's Dictionary fieldtype in the next major version.

@sbrow
Copy link
Contributor Author

sbrow commented Aug 24, 2024

Maybe I'm an idiot, but couldn't countries be saved in flat files? If they were publishable, then users could publish only the countries that they actually service. Then you could piggy-back off of built-in caching and indexing instead of having to roll your own. And instead of having to filter all the world's countries everywhere, you would only have to filter them in edge-cases. 🤷‍♂️

iso: US
name: United States
regions:
  - id: us-ak
    name: Alaska
  - id: us-al
    name: Alabama
# ...

@duncanmcclean
Copy link
Owner

You could maybe try filtering down the returned countries with the only parameter: http://simple-commerce.duncanmcclean.com/tags/countries#content-only

@sbrow
Copy link
Contributor Author

sbrow commented Aug 24, 2024

I was, but it still took forever. I've patched the problem by just hard-coding the countries I need.

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

2 participants