By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,988 Members | 1,068 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,988 IT Pros & Developers. It's quick & easy.

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

P: n/a
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?

May 23 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On 23.05.2007 15:52 we******@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
May 23 '07 #2

P: n/a
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

we******@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.org 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+fYacSNoRApCIAJoCBo/NrAAkgpOl68xxV+L4Tm5onQCeOYWb
kNEGzWnAzf/Jjg2eSVE5A6A=
=I5+3
-----END PGP SIGNATURE-----
May 23 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.