WelcomeUser Guide
ToSPrivacyCanary
DonateBugsLicense

©2025 Poal.co

1.2K

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)

[–] 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?

[–] 0 pt

Poal doesn't use SQL (anymore), and your questions aren't directly related to poal dev, but Peewee and SQL.

I would suggest you to post your questions in