Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Store elements in one database field as an array and count using serve-side language after one read.</strong></p> <p>This one is pretty much bad bad bad. Not only is it bad from a design perspective, but every time you want to count, you have to effectively return all elements. The database spends longer reading actual file pages, as well as longer sending the data back to the client. Once it's on client, you then need to parse it, and then get the count. All taken, this can be FAR slower and is a much worse design.</p> <p><strong>Spreading the array in fields and counting the number of fields using SQL COUNT.</strong></p> <p>The best option of the three, if modified. You don't want to spread the array as fields. You really want to spread it out as rows. You want a 1 to many relationship table. This allows the database to do what it's good at, only accessing the minimum amount of required information, and only returning a single number at the end. Much less work involved for everyone here.</p> <p><strong>Storing a field in database which contains an unpdated value of the sum of elements to count.</strong></p> <p>This can mean two different things. The first is that you have a field that you manually update every time you insert/delete. This would be bad, because it's easy to forget, so why do it? While this could be the most performant of all of the options, it also increases risk. The second, would be to have a calculated column store the count for you. This allows sql server to keep track of it for you, and can be a reasonable option for making queries easier, but can negatively impact performance when you otherwise don't want a count if you grab the entire row. Overall, the second of these isn't bad, but is pretty situational for when it's actually good.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload