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 9168487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:38:13+00:00 2026-06-17T15:38:13+00:00

Possible Duplicate: Is storing a delimited list in a database column really that bad?

  • 0

Possible Duplicate:
Is storing a delimited list in a database column really that bad?

I have been working on a couple of PHP/MySQL projects where all relationships are stored as comma separated strings.

For example a common relationship would be like

(in psuedocode)

table people
id - integer
name - string
age - integer
teams - string (CSV OF integers, ex '1,3,9,21')

table teams
name - String
id - integer

managing relationships becomes a hassle.

To get all teams for a person:

$person = 'SELECT * FROM People WHERE id= x';

then in php I have been doing something like

$person['teams'] = SELECT * FROM teams WHERE id IN ($person['teams']);

as I was writing this i realized i could probably combine them in a mysql query, something like:

SELECT 
  people.id, 
  people.name, 
  people.teams, 
  teams.name 
FROM people 
JOIN teams ON FIND_IN_SET(teams.id, people.teams) WHERE people.id=x

with this type of setup I find myself using FIND_IN_SET, pretty frequently

So finally, my question is: Is there a performance benefit to creating relationships like this?

In my experiences so far FIND_IN_SET has usually been doing a full table scan. If there is no performance benefit, in which instances is it beneficial to using a comma seperated list of integers? It seems that mysql designers had something in mind when creating FIND_IN_SET.

  • 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-17T15:38:14+00:00Added an answer on June 17, 2026 at 3:38 pm

    You’re right, FIND_IN_SET() cannot make use of an index, so it causes a full table scan. Technically, that function is a bogus operation for a relational database, but no doubt there was a lot of demand for it so MySQL implemented it.

    Storing data in a comma-separated list is an example of denormalization. Any departure from normalized design can give a performance boost for one type of query, but usually at the expense of all other types of queries against the same data.

    For example, if you store players and their teams as a comma-separated list, it makes it very easy to get the list of teams for a given player, without doing a join. That’s a performance improvement. But fetching the details for a given player’s teams is much more difficult. Likewise searching for all players on a given team.

    Use comma-separated lists only if that list is treated as a discrete “black box” piece of data. I.e. your application needs to fetch that list as a whole item, but never a subset of the list, and you never need to write SQL to use elements in that list for searching, joining, sorting, subtotals, etc.

    See also my answer to Is storing a delimited list in a database column really that bad?

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

Sidebar

Related Questions

Possible Duplicate: Storing echoed strings in a variable in PHP Suppose I have <?php
Possible Duplicate: Converting Canvas element to Image and storing in database I have a
Possible Duplicate: Storing Images in DB - Yea or Nay? For ages I've been
Possible Duplicate: Can I have a Django model that has a foreign key reference
Possible Duplicate: Can't pass mysqli connection in session in php Many of us have
Possible Duplicate: Encrypting/Hashing plain text passwords in database Recently, I discovered that major web
Possible Duplicate: Splitting string array based upon digits in php? I have a set
Possible Duplicate: Storing Images in DB - Yea or Nay? Images in database vs
Possible Duplicate: PHP image upload security check list I'm setting up a file upload
Possible Duplicate: Storing Images in DB - Yea or Nay? I'm learning PHP and

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.