/    Sign up×
Community /Pin to ProfileBookmark

What SQL indexex should I use for this search?

I need to perform a search to check if at least 1 item exists that satisfies the criteria:
The table is 3 million rows. Each row has “Name”, “Vendor”, “Ticked”, “Favourites” and some other columns.
(if “Ticked”=1 then we ignore this row)
I am using a Fulltext index for the first 2 columns, although the search is still too slow.
**Here is my SQL:**

[code]
SELECT COUNT(`ID`) AS cnt
FROM
(
SELECT * FROM `catalog_”.$partner_table_name.”`
WHERE
(
(
MATCH(`Vendor`) AGAINST(‘”.$brand.”‘)
)
AND
`Favourites`=1
AND
`Ticked`!=’1’
)
LIIMIT 1
) as t”;
[/code]

**My search requirements are:**
1) I want the search for ‘Name’ to NOT be precise but be like ‘LIKE (% . . . %)’
2) Vendor column must search for precise words but not the whole string.
_Example:_
Search : ‘jordan’
Results: ‘Air Jordan’, ‘Jordan’, ‘Nike Jordan’, ‘Nike Air Jordan’

Thank you very much for help!!

to post a comment

0Be the first to comment 😎

×

Success!

Help @weareandrei spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...