Skip to content

database/gdb: add exist feature #3657

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

Closed
wants to merge 4 commits into from
Closed

Conversation

cyjaysong
Copy link
Contributor

database/gdb: add exist feature

)
}
}
return false, nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

直接用Count就可以实现Exist,为什么需要单独加一个方法呢?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

纯粹只是为了开发时方便

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不过我感觉直接使用COUNT,效率不够高,待我优化一下

Copy link
Contributor Author

@cyjaysong cyjaysong Jun 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

查询时生成的sql 为SELECT 1 FROM user_1719281175072039000WHEREid >= 1 LIMIT 1
在单纯需要判断是否存在符合条件的数据,但对数量不敏感时,有limit效率高一些

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cyjaysong 感谢参与贡献,不过这个Exist确实与Count有一些冗余,所以无法合并进入主分支。

@gqcn gqcn added rejected The proposal or PR is not accepted, which might be conflicted with our design or plan. and removed need more details labels Jun 25, 2024
@gqcn gqcn closed this Jun 25, 2024
@cyjaysong cyjaysong deleted the gdb-exist branch June 26, 2024 00:47
@cyjaysong
Copy link
Contributor Author

@gqcn 这个合了吧,业务开发场景挺常用的,虽然Count 能够实现,但是效率肯定没这个方式高啊

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@gqcn That’s it. It’s quite common in business development scenarios. Although Count can be implemented, the efficiency is definitely not as high as this method.

@cyjaysong
Copy link
Contributor Author

使用Count 查询时,生成条件SQL isCountStatement 传递了 true 以至于使用 Limit(1) 和 Count() 组合时,limit 不生效
image
image

@gqcn
Copy link
Member

gqcn commented Oct 14, 2024

@cyjaysong 请重新提交一下pr,我们再重新走一下review流程,该pr已经无法打开了。

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@cyjaysong Please resubmit the PR. We will go through the review process again. The PR cannot be opened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rejected The proposal or PR is not accepted, which might be conflicted with our design or plan.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants