473,721 Members | 2,205 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2500
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.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-----
May 23 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
8126
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 serialized data. Here's a simple example that demonstrates the problem: ----- <?php
7
5142
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 example, given: $data = serialize(array('4.50','0.00','0.00'));
17
1987
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 foo(): (82) 14% C1. def foo() : (235) 41% E1. def foo(): @classmethod (260) 45% Total Votes: 577
28
2388
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 or group of choices: Any J 81 J2 78 Any C 40 C1 29 Any D 9
4
3070
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 called "CHECKBOX"). Each row in the table has this format: a:2:{i:0;s:7:"Peanuts";i:1;s:9:"Cows_milk";}
15
6853
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 the database window open as well? dixie
5
3765
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' VALUE='".$settings."'>"; $settings = $_REQUEST; echo "<P>us=".$settings; $settings_array = Array();
7
2722
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 of the queries work fine when I use them to query the MySQL server directly. My guess is that the MySQL extension only expects a single resource back from the database, but get's several, or that it just checks the statement first, and decides...
10
1819
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 memory access to the database. Also disallows http:// includes. This is where the database of names is stored. This is our internal MySQL server. Server 2 - Only allows shared memory access to the database. So anything that calls the...
0
8860
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9376
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9234
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9150
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9086
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8028
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5994
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3207
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2599
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.