That's probably a project specific issue, we're migrating snippets from D7 and there about 1000 items with custom HTML/CSS/JS for some pages.
In D9 we're faced with memory limit issues, because all that data stored in "config" database table and trying to loading all configs after cache clear.
Ideally snippets should be a content entities, but it will be hard to re-work on current stage, so we're reworked a bit module to store big data in a separate database table, which will be loaded only when it required.

Comments

kiseleva.t created an issue. See original summary.

kiseleva.t’s picture

Status: Needs work » Needs review
Issue tags: +Performance
StatusFileSize
new42.35 KB

By some reason couldn't make a fork with MR, so attached patch here.

Main changes:

  1. Created new database table "snippets"
  2. Added logic to add/update/delete in that table main information about snippets in separate columns and big data like template, css, js, variables as serialised data on snippet save/delete
  3. Excluded template, css, js, variables from storage into "config" table to avoid issues on configs loading (after cache clear for example)
  4. Added an update to create table and re-save all existing snippets so part of data moved from "configs" to "snippets"
  5. Updated Deriver and other places where load multiple used for snippets, instead of that did query to new table to get minimal amount of data, which required for that place
  6. Included changes from https://www.drupal.org/project/snippet_manager/issues/3319720 into that patch, because it also affected by changes
chi’s picture

Ideally snippets should be a content entities.

That would make it impossible to deploy snippets through Drupal configuration system.
I think Snippets as content entities is a completely different use case which needs a different module.

You might want to take a look at Twig Field.

kiseleva.t’s picture

> I think Snippets as content entities is a completely different use case which needs a different module.
Makes sense.

So patch will be helpful if it used as content already and caused issues as in my case.
Corrected an update when no existing snippets, otherwise it failing due to Division by zero.

punamshelke’s picture

Hi

I have added patch for drupal 9.5

punamshelke’s picture

StatusFileSize
new43.23 KB
valery.suslov’s picture

Re-rolled patch #4 for 2.0.1

valery.suslov’s picture

Version: 2.0.1 » 2.x-dev

Reroll #4 for 2.0.1

chetananemade’s picture

Here is the patch compatible with Drupal ^10.3 || ^11.0 for snippet_manager version 3.0.0

chetananemade’s picture

New patch compatible with Drupal ^10.3 || ^11.0 for snippet_manager version 3.0.0