WelcomeUser Guide
ToSPrivacyCanary
DonateBugsLicense

©2025 Poal.co

432

class SubPostComment(BaseModel): cid = CharField(primary_key=True, max_length=40) content = TextField(null=True) lastedit = DateTimeField(null=True) parentcid = ForeignKeyField(db_column='parentcid', null=True, model='self', field='cid') pid = ForeignKeyField(db_column='pid', null=True, model=SubPost, field='pid') score = IntegerField(null=True) upvotes = IntegerField(default=0) downvotes = IntegerField(default=0) status = IntegerField(null=True) # 1=self delete, 2=mod delete, 0 or null=not deleted time = DateTimeField(null=True) uid = ForeignKeyField(db_column='uid', null=True, model=User, field='uid

There is no index for pid. Doesn't it will make retrievng comments for post slow.

class SubPostComment(BaseModel): cid = CharField(primary_key=True, max_length=40) content = TextField(null=True) lastedit = DateTimeField(null=True) parentcid = ForeignKeyField(db_column='parentcid', null=True, model='self', field='cid') pid = ForeignKeyField(db_column='pid', null=True, model=SubPost, field='pid') score = IntegerField(null=True) upvotes = IntegerField(default=0) downvotes = IntegerField(default=0) status = IntegerField(null=True) # 1=self delete, 2=mod delete, 0 or null=not deleted time = DateTimeField(null=True) uid = ForeignKeyField(db_column='uid', null=True, model=User, field='uid There is no index for pid. Doesn't it will make retrievng comments for post slow.

(post is archived)

[–] 1 pt

It depends which db type you are using.

[–] 1 pt

Why poal.co does not index post_id for comments table?

It does. What you are looking at is the default Models.

Poal's tables are already all indexed.

[–] 1 pt

One more question is that is it necessary to index parentcid of comments table? I mean comments are retrieved using pid in where clause. So does parentcid need to be indexed or not? I am confused.

[–] 0 pt

Poal's code differs on how comments are retrieved (compared to Throat default code) since we added advanced sorting with sticky comments.

So yes, it is needed in our case.

[–] 0 pt

I am using peewee for orm. I have already created table using SQL. now when i specify model for that table using peewee. Do i need to specify index=true for column that is already indexed. Is it necessary to specify index=true in peewee model? I am learning peewee for orm?