How to handle 5 million users? ASP.NET Identity

后端 未结 4 1718
你的背包
你的背包 2021-02-06 01:26

I am running a ASP.NET mvc5 app which currently has 5 million users. It is hosted in the Azure cloud. For the authentication I use the Asp.Net Identity for EntityFramework.

4条回答
  •  醉话见心
    2021-02-06 01:59

    I think I have solution for you. I have made another tests and the second option - index on computed column works. Here are steps in sql code, you can probably do the same using EF annotations.

    1. Create computed column on table users as upper(username):

      alter table users add upper_username as upper(username)

    2. Create index on that column:

      create index ix2 on a_upload(upper_username)

    Thats all. The EF select will still use UPPER, but MS SQL optimizer should be able to use this index as it has the same definition as the function in where clause.

    Here are test results on my PC:

    test sql: select field001 from a_upload where upper(field001)='10'

    BEFORE (SCAN means that the engine has to read all records one by one)

    BEFORE

    AFTER CREATING THE INDEX on functional column (SEEK=engine will utilize index)

    enter image description here

    Dont get confuzed that even in the BEFORE scenario, sql engine is using index (ix1). It is only because I am selecting only "field001" and the optimizer knows, that it is contained not only in the table but in the index too. And index has less bytes than whole table. But it does not mean that the system utilized index, it has to compute upper() for every row on each select anyway.

提交回复
热议问题