New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating indexes is very slow #23
Comments
Can you give more some details ? Creating indexs is not too slow unless there are a lot of data rows. |
I am not calling |
Could you test it again with following code ? Or paste your test code that I want to know what happened.
|
Here's my config: SQLALCHEMY_TRACK_MODIFICATIONS=True,
MSEARCH_INDEX_NAME="msearch",
MSEARCH_BACKEND="whoosh",
MSEARCH_ENABLE=True,
TESTING=True,
DATABASE=db_fd.name,
SQLALCHEMY_DATABASE_URI=f"sqlite:///{db_fd.name}", I am using user = User.create_from_credentials(
username="test",
password="test",
email="test@test.com",
verified=True,
verified_time=datetime.utcnow(),
)
get_db().session.add(user)
extra_user = User.create_from_credentials(
username="extra_test",
password="test",
email="b@test.com",
verified=True,
verified_time=datetime.utcnow(),
)
get_db().session.add(extra_user)
get_db().session.commit()
@pytest.fixture
def user(app: flask.Flask):
with app.app_context():
yield User.query.filter_by(username="test").one()
class User(db_instance.Model, UserMixin): # type: ignore
"""User table"""
__table_args__ = (
# named constraint for alembic
UniqueConstraint("email", name="email_unique"),
)
__searchable__ = ["username", "name"]
__msearch_termclass__ = CustomFuzzyTerm
MAX_PASSWORD_LENGTH = 100
MAX_USERNAME_LENGTH = 100
id = Column(Internal_UID(), primary_key=True, autoincrement=True)
username = Column(String(MAX_USERNAME_LENGTH), unique=True)
email = Column(String(255), nullable=True)
password = Column(String(MAX_PASSWORD_LENGTH))
name = Column(String(consts.MAX_NAME_LENGTH))
post_stats = relationship("PostStats", lazy=True, cascade="all")
networks = relationship("Network", lazy=True, cascade="all")
created_time = Column(DateTime, default=datetime.utcnow, nullable=False)
oauth_tokens = relationship("OAuth", cascade="all")
verified = Column(Boolean, default=False)
verified_time = Column(DateTime, nullable=True) The main thing that is causing the slow-down is the |
I have set |
Sorry, I haven't found the problem yet. Could you test it again with |
If the problem persists, you registered some extra signals that time-consuming. If there is no problem, please test
|
My tests are creating new DB rows and before I implemented the library, the tests took about 20 seconds.
When using the library they take about 10 minutes, probably because of the indexes creation. Is there a solution for this?
The text was updated successfully, but these errors were encountered: