Poll's options - two queries to MySQL or Unserialize()?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • webcm123@gmail.com

    Poll's options - two queries to MySQL or Unserialize()?

    I'm making some changes in poll module. I don't know which method of
    storing options of poll is better. The main data of polls are in POLLS
    table.

    Speed and efficiency is the most important issue. There are 2 methods:

    1. Storing options in ANSWERS table and executing 2 queries to get
    poll's data and options. Number of records connected with a poll in
    that table is equal to number of poll's options.

    Fields in ANSWERS table:
    Poll ID | Sequence (optional) | Option | Amount of votes

    2. Storing options in another field in POLLS table. They would be
    being unserialized after getting data from database. Perhaps, it's
    faster method.

    Tests of serialize() and unserialize():
    Seconds: 0.000138 | 9.5E-005
    Miliseconds: 0.122 | 0.095

    What do you think about it? Which method should I use?

  • gosha bine

    #2
    Re: Poll's options - two queries to MySQL or Unserialize()?

    On 23.05.2007 15:52 webcm123@gmail. com wrote:
    I'm making some changes in poll module. I don't know which method of
    storing options of poll is better. The main data of polls are in POLLS
    table.
    >
    Speed and efficiency is the most important issue.
    Nope. Clean code and maintainability is always more important (unless
    you're making software for ballistic missile navigation). ;)

    From this point of view, database solution looks better.
    >
    1. Storing options in ANSWERS table and executing 2 queries to get
    poll's data and options. Number of records connected with a poll in
    that table is equal to number of poll's options.
    >
    Fields in ANSWERS table:
    Poll ID | Sequence (optional) | Option | Amount of votes
    >
    2. Storing options in another field in POLLS table. They would be
    being unserialized after getting data from database. Perhaps, it's
    faster method.
    >
    Tests of serialize() and unserialize():
    Seconds: 0.000138 | 9.5E-005
    Miliseconds: 0.122 | 0.095
    >
    What do you think about it? Which method should I use?
    >



    --
    gosha bine

    extended php parser ~ http://code.google.com/p/pihipi
    blok ~ http://www.tagarga.com/blok

    Comment

    • Edward Z. Yang

      #3
      Re: Poll's options - two queries to MySQL or Unserialize()?

      -----BEGIN PGP SIGNED MESSAGE-----
      Hash: SHA1

      webcm123@gmail. com wrote:
      I'm making some changes in poll module. I don't know which method of
      storing options of poll is better. The main data of polls are in POLLS
      table. [snip]
      Serialize and unserialize are extremely fast, so if you don't mind
      breaking the rules of database normalization and stuff multiple values
      in one column, your second option will be faster.

      - --
      Edward Z. Yang GnuPG: 0x869C48DA
      HTML Purifier <htmlpurifier.o rg Anti-XSS HTML Filter
      [[ 3FA8 E9A9 7385 B691 A6FC B3CB A933 BE7D 869C 48DA ]]
      -----BEGIN PGP SIGNATURE-----
      Version: GnuPG v1.4.6 (MingW32)
      Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

      iD8DBQFGVLrBqTO +fYacSNoRApCIAJ oCBo/NrAAkgpOl68xxV+ L4Tm5onQCeOYWb
      kNEGzWnAzf/Jjg2eSVE5A6A=
      =I5+3
      -----END PGP SIGNATURE-----

      Comment

      Working...