Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9048311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T12:07:39+00:00 2026-06-16T12:07:39+00:00

We have a multitenant application that has a table with 129 fields that can

  • 0

We have a multitenant application that has a table with 129 fields that can all be used in WHERE and ORDER BY clauses. I spent 5 days now trying to find out the best indexing strategy for us, I gained lot of knowledge but I still have some questions.

1) When creating an index should I always make it a composite index with tenant_id in the first place ?(all queries have tenant_id = ? in there WHERE clause)

2) Since all the columns can be used in both the WHERE clause and the order by clause, should I create an index on them all ? (right know when I order by a column that has no index it takes 6s to execute with a tenant that has about 1,500,000 rows )

3) make the PK (tenant_id, ID), but wouldn’t this affect the joins to that table ?

Any advice on how to handle this would be much appreciated.

======
The database engine is InnoDB

=======

structure :

ID bigint(20) auto_increment primary
tenant_id int(11)
created_by int(11)
created_on Timestamp
updated_by int(11)
updated_on Timestamp
owner_id int(11)
first_name VARCHAR(60)
last_name VARCHAR(60)
.
.
.
(some 120 other columns that are all searchable)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T12:07:40+00:00Added an answer on June 16, 2026 at 12:07 pm

    A few brief answers to the questions. As far as I can see you are confused with using indexes

    Consider creating Indexes on columns if the Ratio –

    Consideration 1 –

    (Number of UNIQUE Entries of the Columns)/(Number of Total Entries in the Column) ~= 1

    That is Count of DISTINCT rows in a particular column is high.

    Creating an extra index will always create overhead for the MySQL server, so you MUST NOT create every column an index. There is also a limit on number of indexes your single table can have = 64 per table

    Now if your tenant_id is present in all the search queries, you should consider it as an index or in a composite key,

    provided that –

    Consideration 2 – number of UPDATEs are less that number of SELECTs on the tenant_id

    Consideration 3 – The indexes should be as small as possible in terms of data types. You MUST NOT create a varchar 64 an index
    http://www.mysqlperformanceblog.com/2012/08/16/mysql-indexing-best-practices-webinar-questions-followup/

    Point to Note 1 – Even if you do declare any column an index, MySQL optimizer may still not consider it as best plan of query execution. So always use EXPLAIN to know whats going on. http://www.mysqlperformanceblog.com/2009/09/12/3-ways-mysql-uses-indexes/

    Point to Note 2 –
    You may want to cache your search queries, so remember not to use unpredicted statements in your SELECT queries, such as NOW()

    Lastly – making the PK (tenant_id, ID) should not affect the joins on your table.
    And an awesome link to answer all your questions in general – http://www.percona.com/files/presentations/WEBINAR-MySQL-Indexing-Best-Practices.pdf

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application that in many ways can be considered to be
I have an application that is multitenant, that is, I have multiple clients that
I have an application that uses the grails multi-tenant-core plug-in to host multiple versions
I have a system that we have recently developed - a web application over
In a multi-tenant application I have a table with TenantId column. This table is
I have a need to fluently configure nhibernate in my S#arp application so that
We have an application which is multi-tenant (lots of users all accessing their own
Let's say you have a web application that manages books for book sellers, and
I have an multi-tenant application that uses index aliases with filters. There is just
Can you recommend a CMS framework that could be embedded into existing web application?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.