Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6745937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:15:49+00:00 2026-05-26T12:15:49+00:00

I’m writing a multistore webshop application in PHP/MYSQL. The products table has about a

  • 0

I’m writing a multistore webshop application in PHP/MYSQL. The products table has about a million records, currently i’m having 5 stores with all products in it and about 3 stores with a few products. The product’s price sometimes varies from store to store. Because it should be possible to add or delete certain products for let’s say only shop 2, i created a junction table. My tables looks like this:

products(id,name,description,price,media) ~1M records
stores(id,name)
products_stores(id,product_id,store_id,price) ~5M records

When searching for products the query takes about 20 seconds. I added indices to products(name,description) + products_stores(product_id,store_id). Is there any way I could speed up the process? Most of the records in products_stores are the same (except for the store_id), but I’d like to keep it flexible.

The query:

SELECT 
  Product.id, 
  Product.name, 
  Product.drager, 
  Product.import, 
  Product.price, 
  Product.description, 
  Product.units 
FROM 
  products AS Product 
INNER JOIN 
  products_stores AS ProductStore ON (
    ProductStore.product_id = Product.id 
    AND 
    ProductStore.store_id =1
  ) 
WHERE 
  name LIKE 'bach%' 
ORDER BY 
  Product.description asc 
LIMIT 
  500

I added a FULLTEXT index on only name and deleted the ORDER BY statement, but it seems to make no difference. My indices are now:

Products(name) BTREE
Products(name,description) FULLTEXT
Products(name) FULLTEXT

EXPLAIN of the above query gives: (with indices)
https://i.stack.imgur.com/8Fe8C.gif

Thanks in advance and sorry for my bad English.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:15:49+00:00Added an answer on May 26, 2026 at 12:15 pm

    read the following links about clustered primary keys:

    http://dev.mysql.com/doc/refman/5.0/en/innodb-index-types.html

    http://www.xaprb.com/blog/2006/07/04/how-to-exploit-mysql-index-optimizations/

    MySQL and NoSQL: Help me to choose the right one

    Any way to achieve fulltext-like search on InnoDB

    How to avoid "Using temporary" in many-to-many queries?

    60 million entries, select entries from a certain month. How to optimize database?

    then redesign your product_stores table something along the lines of:

    create table products_stores
    (
    store_id int unsigned not null,
    product_id int unsigned not null,
    ...
    primary key (store_id, product_id)
    )
    engine=innodb;
    

    hope this helps 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I would like to count the length of a string with PHP. The string
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.