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

  • Home
  • SEARCH
  • 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 8101489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:59:32+00:00 2026-06-05T22:59:32+00:00

Consider a table products which has product details including its category. One product may

  • 0

Consider a table products which has product details including its category. One product may belong to multiple category so I’m keeping it as a comma separated list of category IDs.

I know this is not normalized approach.

Can any MYSQL expert tell me that which approach will be faster for selecting products of a particular category.

Obviously we have to JOIN products table and products_category_relation table if take normalized approach.

AND

In my approach we have to write a like query to find the products (assume we are searching for category id 10)

SELECT p.* 
FROM products p
WHERE p.category like '10' 
OR p.category like '10,%'
OR p.category like '%,10'
OR p.category like '%,10,%'

Can any one tell me if this approach is faster or the JOIN approach will be faster?

I know about normalization. I know about other risks involved in my approach. But they do not matter in my case. So, I’m concerned with speed.

Any theoretical explanation about its speed or a practical test result are welcome.

UPDATE

I’m using myISAM engine
product table has Primary Key product_id
FullText index on category column of products table

  • 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-05T22:59:34+00:00Added an answer on June 5, 2026 at 10:59 pm

    A database conforming to the first normal form will be much faster. Your example query cannot use any index and requires a full table scan to resolve. Worse, it must scan the entire text field for all the rows and text work is almost always more expensive than integer work for the computer.

    A normalized table can easily use an index on the category column to speed up the query.

    Text storage may also require more space on disk since numbers are usually more expensive when saved as characters than as the correct integer type (of course there’s some overhead involved in row storage as well).

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

Sidebar

Related Questions

Consider the following table which has the fields - id (int) and date_created (datetime):
Consider we have a database that has a table, which is a record of
Consider: SELECT * FROM `product` left join category on product.category_id = category.id This query
In setting up a MySQL database, consider that I have a table of products
Consider a table like this: folders_table ----------------------- INT id_folder INT id_folder_parent VARCHAR folder_name Which
I'd like to know when you should consider using multiple table in your query
Consider a table with the following schema: id, location, starred There are many records
Consider this table on SQL Server wordID aliasID value =========================== 0 0 'cat' 1
Consider a table or CTE structured like this: Name Num ---- ---- Abc 12
please consider this table: PK_Id Number Year Month Value ------------------------------------------------------------------------- 1 1 2000 5

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.