Home > database >  If I have 1 million of the enterprise name, with the enterprise name like % % to query not walked sl
If I have 1 million of the enterprise name, with the enterprise name like % % to query not walked sl

Time:09-21

Ask a question, I have 1 million of the enterprise name, if the enterprise name like % % to query, is not walk index, query need to take 5 to 7 seconds at a time, if use the full-text search engine, a query result is not completely, because full text search engine is automatically split words, such as tiananmen square in Beijing, can't query, query Beijing day

After using mycat and hadoop, speed up to 2 seconds, but under 50 concurrent, don't walk the index, more than 40 seconds,

Are the solution?

CodePudding user response:

In this way, like an enterprise name % can use an index, but does not know operator does not comply with the requirements;
Key, field or use the LOCATE (name) & gt; 0, try speed

CodePudding user response:

Recommended es do, at the bottom of the reverse index can solve the problem of fuzzy search, need to set up the server, there are many online es tutorial, building good index es performance must be doubled, the contents of the database synchronization to the es can be based on scene,

CodePudding user response:

1 million data is not large, as far as possible put the name field to change the length of the small (such as the actual maximum length of only 50, that is set to 80)
Then try the following approach:
 # 1. Create a temporary table 
CREATE TEMPORARY TABLE TMP (id bigint primary key);

# 2. The related data of the primary key is inserted into a temporary table,
Insert into TMP (id)
Select the id from TB where theName like '% % enterprise name;

# 3. The results of the query to get the actual
Select * from TB as a inner join TMP as b on Anderson, d=b.i d;

# 4. Remove the temporary table
Drop the TEMPORARY table TMP;


Of course, the best practices or ES.

CodePudding user response:

Upstairs, the method of affirmation or slow, still want to go to the full text search,

I recommend the sphinx

CodePudding user response:

reference 4 floor Zerolone response:
way upstairs, affirmation or slow, still want to go to the full text search,

I recommend the sphinx

Don't nonsense, tried again,
The DBA is trying out a lot of things, not to come out

CodePudding user response:

reference 5 floor gypsy song reply:
Quote: refer to 4th floor Zerolone response:

Upstairs, the method of affirmation or slow, still want to go to the full text search,

I recommend the sphinx

Don't nonsense, tried again,
DBA is trying out a lot of things, not think out


reference 5 floor gypsy song reply:
Quote: refer to 4th floor Zerolone response:

Upstairs, the method of affirmation or slow, still want to go to the full text search,

I recommend the sphinx

Don't nonsense, tried again,
DBA is trying out a lot of things, not think out


I am tried, with the like is slow, 100 w,

CodePudding user response:

Search engine, although it was a simple application, also can pack to force, gagarin wages,

CodePudding user response:

refer to 6th floor Zerolone response:
Quote: refer to fifth floor gypsy song response:

Quote: refer to 4th floor Zerolone response:

Upstairs, the method of affirmation or slow, still want to go to the full text search,

I recommend the sphinx

Don't nonsense, tried again,
DBA is trying out a lot of things, not think out


reference 5 floor gypsy song reply:
Quote: refer to 4th floor Zerolone response:

Upstairs, the method of affirmation or slow, still want to go to the full text search,

I recommend the sphinx

Don't nonsense, tried again,
DBA is trying out a lot of things, not think out


I am tried, with the like is slow, 100 w,

You try to use my code, rather than use your way,

CodePudding user response:

You LIKE here QiYeMing, QiYeMing should be have a dictionary table or something LIKE that, can you add a field alone, storage QiYeMing, it is best to save the enterprise ID, and then directly equals the query,
  • Related