Factor {users_field_data}.access out of the table and entity caches

Created on 8 November 2012, over 12 years ago
Updated 11 July 2025, about 18 hours ago

The problem

Follow-up from: #1488630: Who's online block doesn't work with swappable session backends and lazy session creation β†’ and #40545: Improve speed by avoiding unnecessary updates in sess_write() β†’ .

UserRequestSubscriber updates the {user_field_data}.access column for every auth user, every three minutes by default.

This means a write to a high-read table, invalidating the query cache for it.

Additionally we invalidate the persistent entity cache, which means several queries and a cache set on the next request if the current user account is loaded every request.

If you have a site with lots of authenticated users, this can mean a lot of database churn and cache invalidations.

Then we only use the information on user profile rendering to admins, and admin views by default, which is very rarely viewed compared to the number of times account objects get loaded (Ev

Both last access and last login are really activity logging, not properties of the user.

Proposed solution

Add a new service, maintaining its own storage, that handles getting and setting last access.

For backwards compatibility, call that service from UserStorageController - but leave out the field tables and entity cache.

Also needs views integration for the new table in a way that will work.

Remaining tasks

Agree this is a good idea. Possibly profiling to show how bad things are currently.

πŸ“Œ Task
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

base system

Created by

πŸ‡¬πŸ‡§United Kingdom catch

Live updates comments and jobs are added and updated live.
  • Performance

    It affects performance. It is often combined with the Needs profiling tag.

  • stale-issue-cleanup

    To track issues in the developing policy for closing stale issues, [Policy, no patch] closing older issues

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Thank you for creating this issue to improve Drupal.

    We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.

    Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

  • πŸ‡¨πŸ‡­Switzerland berdir Switzerland

    I think this is still a valid idea.

  • πŸ‡¬πŸ‡§United Kingdom catch

    Yeah the problem is still there in exactly the same way and as before the main problem is views support, without that we could use key/value or key/value expirable.

    I think we first need to decide whether we need this in core, and secondly whether it needs views support.

    Tagging with needs product manager review for that.

Production build 0.71.5 2024