Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…4/why-does-postgresql-perform-a-seq-scan-when-comparing-a-numeric-value-with-a-big/339617#339617 by explicitly setting column type `bigint` for all entity fields which typed with `ulong` @ c#
  • Loading branch information
n0099 committed May 18, 2024
1 parent 1413923 commit fa16951
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions c#/crawler/src/Db/Post/BasePost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace tbm.Crawler.Db.Post;

public abstract class BasePost : TimestampedEntity, ICloneable
{
[Column(TypeName = "bigint")]
public ulong Tid { get; set; }
public long AuthorUid { get; set; }

Check notice on line 9 in c#/crawler/src/Db/Post/BasePost.cs

View workflow job for this annotation

GitHub Actions / ReSharper

"[UseSymbolAlias] Use type alias 'Uid'" on /home/runner/work/open-tbm/open-tbm/c#/crawler/src/Db/Post/BasePost.cs(9,280)
public uint? LastSeenAt { get; set; }
Expand Down
3 changes: 2 additions & 1 deletion c#/crawler/src/Db/Post/PostContent/ReplyContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ namespace tbm.Crawler.Db.Post.PostContent;

public class ReplyContent : BasePostContent
{
[Key] public ulong Pid { get; set; }
[Key] [Column(TypeName = "bigint")]
public ulong Pid { get; set; }
}
3 changes: 2 additions & 1 deletion c#/crawler/src/Db/Post/PostContent/SubReplyContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ namespace tbm.Crawler.Db.Post.PostContent;

public class SubReplyContent : BasePostContent
{
[Key] public ulong Spid { get; set; }
[Key] [Column(TypeName = "bigint")]
public ulong Spid { get; set; }
}
3 changes: 2 additions & 1 deletion c#/crawler/src/Db/Post/ReplyPost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ namespace tbm.Crawler.Db.Post;

public class ReplyPost : PostWithAuthorExpGrade
{
[Key] public ulong Pid { get; set; }
[Key] [Column(TypeName = "bigint")]
public ulong Pid { get; set; }
public uint Floor { get; set; }
public required ReplyContent Content { get; set; }

Expand Down
4 changes: 3 additions & 1 deletion c#/crawler/src/Db/Post/SubReplyPost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ namespace tbm.Crawler.Db.Post;

public class SubReplyPost : PostWithAuthorExpGrade
{
[Column(TypeName = "bigint")]
public ulong Pid { get; set; }
[Key] public ulong Spid { get; set; }
[Key] [Column(TypeName = "bigint")]
public ulong Spid { get; set; }
public required SubReplyContent Content { get; set; }

[JsonConverter(typeof(ProtoBufRepeatedFieldJsonConverter<Content>))]
Expand Down
3 changes: 2 additions & 1 deletion c#/crawler/src/Db/Post/ThreadMissingFirstReply.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ namespace tbm.Crawler.Db.Post;

public class ThreadMissingFirstReply : RowVersionedEntity
{
[Key] public ulong Tid { get; set; }
[Key] [Column(TypeName = "bigint")]
public ulong Tid { get; set; }
public ulong? Pid { get; set; }
public byte[]? Excerpt { get; set; }
public uint? LastSeenAt { get; set; }
Expand Down
1 change: 1 addition & 0 deletions c#/crawler/src/Db/Post/ThreadPost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class ThreadPost : BasePost
[JsonConverter(typeof(ProtoBufRepeatedFieldJsonConverter<Abstract>))]
[NotMapped]
public RepeatedField<Abstract>? FirstReplyExcerpt { get; set; }
[Column(TypeName = "bigint")]
public ulong ThreadType { get; set; }
public string? StickyType { get; set; }
public string? TopicType { get; set; }
Expand Down
1 change: 1 addition & 0 deletions c#/crawler/src/Db/Revision/Splitting/ReplyRevisions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace tbm.Crawler.Db.Revision.Splitting;

public abstract class BaseReplyRevision : RevisionWithSplitting<BaseReplyRevision>
{
[Column(TypeName = "bigint")]
public ulong Pid { get; set; }
}

Expand Down
1 change: 1 addition & 0 deletions c#/crawler/src/Db/Revision/Splitting/SubReplyRevisions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace tbm.Crawler.Db.Revision.Splitting;

public abstract class BaseSubReplyRevision : RevisionWithSplitting<BaseSubReplyRevision>
{
[Column(TypeName = "bigint")]
public ulong Spid { get; set; }
}

Expand Down
1 change: 1 addition & 0 deletions c#/crawler/src/Db/Revision/Splitting/ThreadRevisions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace tbm.Crawler.Db.Revision.Splitting;

public abstract class BaseThreadRevision : RevisionWithSplitting<BaseThreadRevision>
{
[Column(TypeName = "bigint")]
public ulong Tid { get; set; }
}

Expand Down
3 changes: 3 additions & 0 deletions c#/shared/src/Db/ReplyContentImage.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
// ReSharper disable PropertyCanBeMadeInitOnly.Global
using System.ComponentModel.DataAnnotations.Schema;

namespace tbm.Shared.Db;

public class ReplyContentImage : EntityWithImageId
{
[Column(TypeName = "bigint")]
public ulong Pid { get; set; }
public required ImageInReply ImageInReply { get; set; }
}

0 comments on commit fa16951

Please sign in to comment.