i have Rails application with "devise_token_auth" gem. I noticed a very slow SQL update when access token expires, and a new access token is saved in User.
I noticed that the users table is locked during the update, but looking at the gem code that should not take to much time. And I have the index on the users table. All other queries in the application are normal (fast).
Those are details of this query:
SELECT "users".* FROM "users" WHERE "users"."id" = $? LIMIT $? FOR UPDATE
Duration1,400 ms
Explain plan
Query planLimit (cost=0.29..8.31 rows=1 width=2598)
Query plan-> LockRows (cost=0.29..8.31 rows=1 width=2598)
Query plan-> Index Scan using users_pkey on users (cost=0.29..8.30 rows=1 width=2598)
Query plan Index Cond: ?
…ted-x.x.x/lib/attr_encrypted/adapters/active_record.rb: 11:in `reload'
…matapp/.rbenv/versions/x.x.x/lib/ruby/x.x.x/monitor.rb: 214:in `mon_synchronize'
…ollers/devise_token_auth/concerns/set_user_by_token.rb: 100:in `update_auth_header'
Any idea what is happening here?