Skip to content

Commit

Permalink
Add index for sd_hash
Browse files Browse the repository at this point in the history
limit content type column during processing
  • Loading branch information
tiger5226 committed May 1, 2020
1 parent c5199f4 commit 94f010e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion daemon/processing/claim.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,12 @@ func setSourceInfo(claim *model.Claim, helper *c.ClaimHelper) {
if stream != nil {
source := stream.GetSource()
if source != nil {
claim.ContentType.SetValid(source.GetMediaType())
const maxContentTypeLength = 162
mediaType := source.GetMediaType()
if len(mediaType) > maxContentTypeLength {
mediaType = mediaType[:158] + "..."
}
claim.ContentType.SetValid(mediaType)
sdHash := hex.EncodeToString(stream.GetSource().GetSdHash())
const maxSDHashColLength = 120
if len(sdHash) > maxSDHashColLength {
Expand Down
6 changes: 6 additions & 0 deletions migration/023_sdhash_index.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- +migrate Up

-- +migrate StatementBegin
ALTER TABLE `chainquery`.`claim`
ADD INDEX `Idx_sdhash` (`sd_hash` ASC);
-- +migrate StatementEnd

0 comments on commit 94f010e

Please sign in to comment.