Skip to content

Adjust index_users_for_active_billable to be correct

Mohamed Hamda requested to merge rename_index_users_for_active_billable into master

What does this MR do and why?

This MR is a follow-up on this suggestion

Based on the above, if I'm correct(please double check me)... we should

  1. allow !107290 (merged) to handle the billable bot analysis and index
  2. fix this index for the original use - rename and remove 4,5 from it.

This MR handles:

  1. fix this index for the original use - rename and remove 4,5 from it.

We adjusted the index name before to be index_users_for_active_billable, while the bots are not billable

The new name seems more accurate based on that comment

We also added service_user(4) and ghost(5) to the index, while it was not there previously, so we are removing them.

More details about the original index could be found here

Migrations:

Up:

main: == 20221221115621 AdjustIndexUsersForActiveBillable: migrating ================
main: -- transaction_open?()
main:    -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main:    -> 0.0821s
main: -- index_exists?("users", [:id], {:where=>"((state)::text = 'active'::text) AND ((user_type IS NULL)\nOR (user_type = ANY (ARRAY[NULL::integer, 6, 4]))) AND ((user_type IS NULL)\nOR (user_type <> ALL ('{1,2,3,6,7,8,9,11}'::smallint[])))\n", :name=>"index_users_id_for_active_humans_or_non_internal_without_bots", :algorithm=>:concurrently})
main:    -> 0.0115s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0004s
main: -- add_index("users", [:id], {:where=>"((state)::text = 'active'::text) AND ((user_type IS NULL)\nOR (user_type = ANY (ARRAY[NULL::integer, 6, 4]))) AND ((user_type IS NULL)\nOR (user_type <> ALL ('{1,2,3,6,7,8,9,11}'::smallint[])))\n", :name=>"index_users_id_for_active_humans_or_non_internal_without_bots", :algorithm=>:concurrently})
main:    -> 0.0041s
main: -- execute("RESET statement_timeout")
main:    -> 0.0002s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main:    -> 0.0005s
main: -- indexes("users")
main:    -> 0.0257s
main: -- remove_index("users", {:algorithm=>:concurrently, :name=>"index_users_for_active_billable"})
main:    -> 0.0018s
main: == 20221221115621 AdjustIndexUsersForActiveBillable: migrated (0.1411s) =======

Down:

main: == 20221221115621 AdjustIndexUsersForActiveBillable: reverting ================
main: -- transaction_open?()
main:    -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main:    -> 0.1391s
main: -- index_exists?("users", [:id], {:where=>"((state)::text = 'active'::text) AND ((user_type IS NULL)\nOR (user_type = ANY (ARRAY[NULL::integer, 6, 4]))) AND ((user_type IS NULL)\nOR (user_type <> ALL ('{1,2,3,4,5,6,7,8,9,11}'::smallint[])))\n", :name=>"index_users_for_active_billable", :algorithm=>:concurrently})
main:    -> 0.0127s
main: -- execute("SET statement_timeout TO 0")
main:    -> 0.0005s
main: -- add_index("users", [:id], {:where=>"((state)::text = 'active'::text) AND ((user_type IS NULL)\nOR (user_type = ANY (ARRAY[NULL::integer, 6, 4]))) AND ((user_type IS NULL)\nOR (user_type <> ALL ('{1,2,3,4,5,6,7,8,9,11}'::smallint[])))\n", :name=>"index_users_for_active_billable", :algorithm=>:concurrently})
main:    -> 0.0036s
main: -- execute("RESET statement_timeout")
main:    -> 0.0008s
main: -- transaction_open?()
main:    -> 0.0000s
main: -- view_exists?(:postgres_partitions)
main:    -> 0.0008s
main: -- indexes("users")
main:    -> 0.0262s
main: -- remove_index("users", {:algorithm=>:concurrently, :name=>"index_users_id_for_active_humans_or_non_internal_without_bots"})
main:    -> 0.0014s
main: == 20221221115621 AdjustIndexUsersForActiveBillable: reverted (0.2052s) =======

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Mohamed Hamda

Merge request reports