You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "MillionMao (via GitHub)" <gi...@apache.org> on 2025/07/16 06:42:11 UTC

[I] How to use postgres Self-increasing sequence rather than key‐generate‐strategy? [shardingsphere]

MillionMao opened a new issue, #36022:
URL: https://github.com/apache/shardingsphere/issues/36022

   version:sharding 5.5.1
   
   I haven't configured key‐generate‐strategy,but sharding was automatically generated filed "id",it looks like Long integer.
   
   In fact, the auto-increment of the database is not used at all.
   
   logic sql :   insert into table_a(task ,name) values('111', 'aaa');
   
   actual sql:   insert into table_a(task ,name, id) values('111', 'aaa', 1152241065663660032);


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] How to use postgres Self-increasing sequence rather than key‐generate‐strategy? [shardingsphere]

Posted by "linghengqian (via GitHub)" <gi...@apache.org>.
linghengqian commented on issue #36022:
URL: https://github.com/apache/shardingsphere/issues/36022#issuecomment-3125758405

   > logic sql :   insert into table_a(task ,name) values('111', 'aaa');
   > 
   > actual sql:   insert into table_a(task ,name, id) values('111', 'aaa', 1152241065663660032);
   
   - I believe this is a table name conflict. The logical table name you configured is a duplicate of a known real table, resulting in incorrect table routing.
   
   - This is actually the expected behavior, unless your logical table names do not conflict with any real table name.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] How to use postgres Self-increasing sequence rather than key‐generate‐strategy? [shardingsphere]

Posted by "linghengqian (via GitHub)" <gi...@apache.org>.
linghengqian commented on issue #36022:
URL: https://github.com/apache/shardingsphere/issues/36022#issuecomment-3125715198

   > table_a doesn't store data.
   
   - So, since there is a real table called `table_a`, what name is used for the logical table in your shardingsphere configuration file? Can you share a git containing a unit test with a minimal reproducible error? The database instance can use testcontainers-java.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] How to use postgres Self-increasing sequence rather than key‐generate‐strategy? [shardingsphere]

Posted by "MillionMao (via GitHub)" <gi...@apache.org>.
MillionMao commented on issue #36022:
URL: https://github.com/apache/shardingsphere/issues/36022#issuecomment-3125702891

   Yes, both table_a and  table_a_202507 exist in the database at the same time, and a partitioned table is generated regularly based on table_a every month. table_a doesn't store data.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] How to use postgres Self-increasing sequence rather than key‐generate‐strategy? [shardingsphere]

Posted by "linghengqian (via GitHub)" <gi...@apache.org>.
linghengqian commented on issue #36022:
URL: https://github.com/apache/shardingsphere/issues/36022#issuecomment-3124493082

   > For example:
   > Original table: table_a
   > Partitioned table: table_a_202507
   
   - I don't see what you are referring to. Do both `table_a` and `table_a_202507` exist in your real database? What is the configuration of the logical databases and logical tables of ShardingSphere?
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] How to use postgres Self-increasing sequence rather than key‐generate‐strategy? [shardingsphere]

Posted by "MillionMao (via GitHub)" <gi...@apache.org>.
MillionMao commented on issue #36022:
URL: https://github.com/apache/shardingsphere/issues/36022#issuecomment-3083679665

   I found a solution !
   
   For example:
   Original table: table_a
   Partitioned table: table_a_202507
   
   Remove the auto-increment of the primary key of table_a and retain that of table_a_202507.
   
   Something magical happened.
   
   The auto-increment of the primary key in the database has taken effect !


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] How to use postgres Self-increasing sequence rather than key‐generate‐strategy? [shardingsphere]

Posted by "MillionMao (via GitHub)" <gi...@apache.org>.
MillionMao commented on issue #36022:
URL: https://github.com/apache/shardingsphere/issues/36022#issuecomment-3125739889

   ```dataSources:
     master:
       dataSourceClassName: com.alibaba.druid.pool.DruidDataSource
       driverClassName: org.postgresql.Driver
       jdbcUrl: jdbc:postgresql://127.0.0.1:5432/db_primary?currentSchema=public
       username: xxx
       password: xxx
   
   rules:
   
     - !BROADCAST
       tables:
         - table_a
     - !SHARDING
       tables:
         table_a:
           actualDataNodes: master.table_a_$->{2025..2099}$->{(1..12).collect{t -> t.toString().padLeft(2, '0')}}
           tableStrategy:
             standard:
               shardingColumn: create_time
               shardingAlgorithmName: data-algorithm
       shardingAlgorithms:
         data-algorithm:
           type: CLASS_BASED
           props:
             strategy: STANDARD
             algorithmClassName: com.xxx.xxx.xxx```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] How to use postgres Self-increasing sequence rather than key‐generate‐strategy? [shardingsphere]

Posted by "MillionMao (via GitHub)" <gi...@apache.org>.
MillionMao commented on issue #36022:
URL: https://github.com/apache/shardingsphere/issues/36022#issuecomment-3125703270

   dataSources:
     master:
       dataSourceClassName: com.alibaba.druid.pool.DruidDataSource
       driverClassName: org.postgresql.Driver
       jdbcUrl: jdbc:postgresql://127.0.0.1:5432/db_primary?currentSchema=public
       username: xxx
       password: xxx
   
   rules:
     - !BROADCAST
       tables:
         - table_a
     - !SHARDING
       tables:
         table_a:
           actualDataNodes: master.table_a_$->{2025..2099}$->{(1..12).collect{t -> t.toString().padLeft(2, '0')}}
           tableStrategy:
             standard:
               shardingColumn: create_time
               shardingAlgorithmName: data-algorithm
       shardingAlgorithms:
         data-algorithm:
           type: CLASS_BASED
           props:
             strategy: STANDARD
             algorithmClassName: com.xxx.xxx.xxx


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] How to use postgres Self-increasing sequence rather than key‐generate‐strategy? [shardingsphere]

Posted by "MillionMao (via GitHub)" <gi...@apache.org>.
MillionMao commented on issue #36022:
URL: https://github.com/apache/shardingsphere/issues/36022#issuecomment-3125743599

   ```dataSources:
     master:
       dataSourceClassName: com.alibaba.druid.pool.DruidDataSource
       driverClassName: org.postgresql.Driver
       jdbcUrl: jdbc:postgresql://127.0.0.1:5432/db_primary?currentSchema=public
       username: xxx
       password: xxx
   
   rules:
     - !BROADCAST
       tables:
         - table_a
   
     - !SHARDING
       tables:
         table_a:
           actualDataNodes: master.table_a_$->{2025..2099}$->{(1..12).collect{t -> t.toString().padLeft(2, '0')}}
           tableStrategy:
             standard:
               shardingColumn: create_time
               shardingAlgorithmName: data-algorithm
       shardingAlgorithms:
         data-algorithm:
           type: CLASS_BASED
           props:
             strategy: STANDARD
             algorithmClassName: com.xxx.xxx.xxx```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] How to use postgres Self-increasing sequence rather than key‐generate‐strategy? [shardingsphere]

Posted by "linghengqian (via GitHub)" <gi...@apache.org>.
linghengqian closed issue #36022: How to use postgres Self-increasing sequence rather than key‐generate‐strategy?
URL: https://github.com/apache/shardingsphere/issues/36022


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] How to use postgres Self-increasing sequence rather than key‐generate‐strategy? [shardingsphere]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #36022:
URL: https://github.com/apache/shardingsphere/issues/36022#issuecomment-3152728978

   There hasn't been any activity on this issue recently, and in order to prioritize active issues, it will be marked as stale.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org