473,394 Members | 1,751 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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?

May 23 '07 #1
2 2469
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
-----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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mark | last post by:
Greetings: So, I've got a real problem in that PHP doesn't seem to be able to unserialize() an array that has an element containing a newline. Of course, I've used htmlentities() to protect the...
7
by: richbl | last post by:
Hello all, I have a question about unserializing a single array element from a serialized array. Can this be done, or must I first unserialize the array, and then access the element? For...
17
by: Doug Holton | last post by:
George W Bush, as certified by Florida's election commission. Which decorator syntax do you like the most? See http://wiki.wxpython.org/index.cgi/PythonDecoratorsPoll A. @classmethod def...
28
by: Paul McGuire | last post by:
Well, after 3 days of open polling, the number of additional votes have dropped off pretty dramatically. Here are the results so far: Total voters: 55 (with 3 votes each) Votes for each choice...
4
by: Bee | last post by:
Hi everyone, I'm having trouble accessing a Mysql database containing checkbox data that is posted from a form. I use the serialize function to store the checkbox values in an array (in a column...
15
by: dixie | last post by:
I have a command to open the Access Options dialogue from code: DoCmd.RunCommand acCmdOptions It also opens the Database Window behind it. Is it possible to open the Options without having...
5
by: Mike | last post by:
I finally got serialize to work but now I cannot get unserialize to work. Here is my code. $settings = serialize($settings_array); echo "<INPUT TYPE='Hidden' NAME='settings'...
7
by: Daz | last post by:
Hi. I am trying to select data from two separate MySQL tables, where I cannot use join, but when I put the two select queries into a single query, I get an error telling me to check my syntax. Both...
10
by: Jerim | last post by:
I am attempting to put together one script that pulls data from one database on its own server, and data from another database on its own server, which is off-site. Server 1 - Only allows shared...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.