black friday sale

Custom Fields
Re-Envisioned
Support MB Custom Table Speed when using Custom Table

  • Creator
    Topic
  • #22574
    Resolved Trang Nguyen
    Participant

    Hi team!
    Let say I have these fields: website, email, phone, fax, street_address, city, country, logo, slogan…
    As I know I have 2 ways to save data into a custom table:
    1. Create columns in the table for each field.
    2. Create a group field and put these fields into that group, and then create 1 column for that group field (I’ll create more groups/columns, also nested groups for other data).

    From the viewpoint of speed, which way is faster if I want to show the data fields to the front end?

    Many thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #22579
    Long Nguyen
    Moderator

    Hi,

    Point 1 always gets the data (field value) faster than point 2 for some reasons:

    • Point 1:
    • Get only one field value.
      (Note that the call to the custom table will be cached, e.g. if you call the helper function several times for the same $post_id, it will only query once)
    • Show the field value directly without using the loop.

    • Point 2:

    • Get a group of field values.
    • Need to use the loop to show sub-field value.
    • Cannot query by sub-field value.
      https://docs.metabox.io/extensions/mb-custom-table/#group-fields

    Totally, it’s up to your requirements.

    #22582
    Trang Nguyen
    Participant

    Many thanks for your clear explanation, Long!
    Have a nice day!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.