Results 1 to 7 of 7

Thread: Fastest database mysql, mysqli, pdo, postgresql?

  1. #1
    Join Date
    Oct 2011

    Fastest database mysql, mysqli, pdo, postgresql?

    I'm trying to make a fast website. The css / javascript etc is already minifyd. But now I want to make my database faster.
    I know it's all about indexes and structures but even when that is already done well.
    What schould I use by then?
    Mysql, mysqli, pdo or postgresql?

    I was using mysql but then people said mysqli was faster. Than people said choose mysqli for speed and pdo for functionallity now they are saying choose pdo it's also faster. So what is really the fastest? and again I know it's all about structure your database and index it but let's say that is already totally right.

    Already thank you!


  2. #2
    Join Date
    Aug 2004
    MySQLi is still MySQL, it's just an improved API for accessing it. It *might* have some performance improvements in terms of the API code, but it will not affect how fast the actual queries execute. (You may get some improvements by using prepared statements in MySQLi, but that can be situation-dependent.) Likewise, PDO is a DBMS-agnostic interface that allows you to use many different DBMS's via the same interface, and as such won't affect how fast your queries execute.

    So from your post, as far as DBMS's go, you're talking about MySQL or PostgreSQL. From what I've read, current versions are pretty comparable speed-wise when you use MyISAM table types in MySQL, but then you miss out on some features, notably transactions.

    These days, a popular approach when data speed becomes an issue is a "No SQL" solution, such as MongoDB; though there are plenty of reasons to consider the pros and cons before jumping to such a solution.
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  3. #3
    Join Date
    Oct 2011
    Thanks for the information,
    I think the conclusion is: There is no speed differences only functionality.
    Am I right?

  4. #4
    Join Date
    Jul 2010
    That's how I see it. You can do 100 different things to improve database performance. It can't be explained in 10,000 characters or less, which makes a forum post a bad idea.

    The speed can be determined by:

    data structure
    how well the queries take advantage of the data structures
    application layer
    .. things I missed ...

    If the network is REALLY slow then it may not be worth fetching raw data from MySQL. Instead, it might be faster to have MySQL transform the data and return you a smaller result. The raw data could be processed in MySQL or the application layer, it just happens to be faster overall to run it through a stored procedure in MySQL than it is to fetch the raw data and transform it on the application layer.

    So it's not so strait forward, there are a lot of issues like this. Logs are great for integrity, binary log, slow query log, query log, etc etc. But it takes time to write that all to disk.

    For whatever it's worth, I was told by someone that a single disk strike (reading data from the disk) is comparable to ~1,000,000 operations in the CPU. So if you're reading from disk, you might consider trying to find ways to not read from disk. That's part of what databases are trying to minimise. The B-Tree (balanced tree) is a resilient data structure for this, because if you can search using a TINY little index, then you can find out where the correct place on disk to strike is very fast. You can make GIANT balanced tress with billions of entries. The index/btree can add another row of nodes with exponentially more data than the last row. So as the maximum time to compare and traverse to any given node on a btree goes up in a linear fashion, the amount of data you can store goes up in an exponential fashion. I say "fashion", because there are certain limitations again, such as hardware. The index may not fit in memory, etc... it's not some perfect function.

    If you want to store a crap ton of data and it's obvious you will need to strike the disk to access it (5TB of data), use a database. They are designed for this.

    If you only have a tiny amount of data that can fit into memory, then the fastest option is to not use a database. You would only be slowing yourself down. There exists a myriad of options for storing data. MySQL is just one of them.

    So what is really the fastest?

    Back to your question about mysqli mysql_* and PDO... I use PDO, and in certain situations it is incredibly faster than mysql_* functions. But in general, they are all perfectly fine. I would hate for you to miss out on some of the really cool functionality in PDO.
    I use (, ; : -) as I please- instead of learning the English language specification: I decided to learn Scheme and Java;

  5. #5
    Join Date
    Feb 2012
    It depends on the complexity of your SQL queries.
    If you use SQL queries with complicated joins than PostgreSQL will give you faster performance than MySQL on average.
    If you have just simple SELECT and UPDATE queries on one or two tables than MySQL is your best choice.
    To go to the extreme use MySQL 4 - it is faster.

  6. #6
    Join Date
    Oct 2009
    If I may, I'd like to point out that the question was about the speed of the database. So I guess we should isolate the answer to the database architecture. I guess there is a misconception that PDO and MySQLi is a database. It is technically not. To answer the question it is based on the configuration of the database.

    E.g. In MSSQL the leaf size is 8MB. Meaning each node of the B-Tree will have 8MB of data in it before it creates another child. In MySQL you can increase this by changing the block size. In MyISAM engines modify the .myi. In postgresql this is also configurable. In fact in postgresql you can even query the nodes directly. However, given same configuration there is no benchmark as to which is faster between them as that would require a low level analysis.
    Good Luck

    Santos Systems

  7. #7
    Join Date
    Feb 2012
    MySQLI is the way to go man!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.11352 seconds
  • Memory Usage 2,906KB
  • Queries Executed 15 (?)
More Information
Template Usage (33):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (7)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • bbcode_parse_start
  • postbit_imicons
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates