WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] About Optimizing Querying Posts by Custom Fields (6 posts)

  1. Muhammad Mahmoud
    Member
    Posted 4 years ago #

    Hi all

    first .. sorry 4 my english :)

    i am web developer and using wordpress as framework for any Customized CMS i want build

    if i want to make a video Cms for example and want to make keys for videos instead of ID'S

    each video is post has ID , and Customfield ( "vkey" => "1A2B3C" )

    each post will have the customfield ( "vkey" )

    so i want to make a custom page to view video by key

    example.com/vid/ANYKEYHERE

    will take the key and QueryPost it

    my question here
    if i will have more than 1,000,000 Videos [ POSTS ]

    i looked up at ("POSTMETA") table structure @ wordpress database
    and ofcourse they cant make this field ("UNIQUE")
    or Indexed coz this field may have alot of similar values like values of key ( _edit_last )

    so i think the query will look at all ("vkey") values to find the one matching the Key comes from URL

    i ask about this coz this page will be the most visited page at the cms and we will have alot of visits when we lunch it

    i hope that any body can get what i talk about .. coz i know my bad english :(

    Thanks in Advance

  2. vtxyzzy
    Member
    Posted 4 years ago #

    One possible solution (but not simple) would be to have your own table containing vkey-values and post ID, indexed on vkey-value. Then use hooks to update the table whenever a post is added, updated, or deleted.

  3. Muhammad Mahmoud
    Member
    Posted 4 years ago #

    it's right
    but is there any simpler solution ?

  4. MichaelH
    Member
    Posted 4 years ago #

    Can't speak to the performance of that situation, but look at http://wordpress.org/extend/plugins/custom-field-taxonomies/

    Also see:
    WordPress_Optimization

  5. scribu
    Member
    Posted 4 years ago #

    I would add the vkey column to the wp_posts table directly. You can make it unique and you avoid a JOIN.

  6. Muhammad Mahmoud
    Member
    Posted 4 years ago #

    @MichaelH

    Thanks for your attention .. but this plug wasnt to get what i mean

    @ Scribu

    Thanks for your reply .. it's similar to vtxyzzy's idea

    i asked PHP Web Developer .. his name is Burak Guzel [phpandstuff.com]

    and he helped me that i can make index(non-unique) to the field with a specific length even it's type is TEXT

    e.g. i will index the first 20 charachters from this field
    -->
    alter table wp_postmeta ADD INDEX ( meta_value ( 20 ) )

    Thanks 4 All

Topic Closed

This topic has been closed to new replies.

About this Topic