Re: Re:Re: Re:Re: index about jdbc thin mode
Hi, Your configuration perfectly works on my side. Make sure that you are connecting to the server node with an appropriate configuration of indexes. I'm afraid, that without a complete reproducer it's not possible to figure out the reason. Kind regards, Alex -- Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re:Re: Re:Re: index about jdbc thin mode
The code is here: String sql = "explain SELECT FID,FNUMBER FROM \"customerCache\".CustomerIgniteInfo WHERE FUSEDSTATUS = 3)"; Class.forName("org.apache.ignite.IgniteJdbcThinDriver"); Connection conn = DriverManager.getConnection("jdbc:ignite:thin://192.168.63.36?distributedJoins=true"); PreparedStatement preparedStatement = conn.prepareStatement(sql); The configuration can see the attachment. Can transaction cause this problem? I also use spring with my project. package com.kingdee.ignite.common.config; import javax.cache.configuration.MutableConfiguration; import org.apache.ignite.cache.CacheMode; import org.apache.ignite.cache.CacheWriteSynchronizationMode; import org.apache.ignite.configuration.CacheConfiguration; import com.kingdee.ignite.common.dao.SqlCustomFunction; public abstract class AbstractCacheConfigurationextends CacheConfiguration { private static final long serialVersionUID = 6000710247906756326L; public AbstractCacheConfiguration(){ initialization(); } public void initialization(){ //设置é»è®¤å¤ä»½èç¹0 setDefaultBackups(); //设置é»è®¤ååºç¼å setDefaultCacheMode(); //设置é»è®¤åæ¥å¤ä»½ //çå¾ ä¸»èç¹çåæè æ交æä½å®æ //ä½æ¯ä¸çå¾ å¤ä»½èç¹æ´æ°å®æ setDefaultWriteSynchronizationMode(); //éå setDefaultWriteThrough(); //é»è®¤å¯ç¨åå setDefaultWriteBehindEnabled(); //é»è®¤å¯ç¨é读 setDefaultReadThrough(); //ååå·æ°é»è®¤è®¾ç½®ä¸º10240 setDefaultWriteBehindFlushSize(); //æ¯é10ç§ ååå·æ° setDefaultWriteBehindFlushFrequency(); //设置æä¹ åå°æ°æ®åºçè®°å½æ°ï¼1 setWriteBehindBatchSize(); setWriteBehindFlushThreadCount(); //å平衡æ¶æ¯ç大å°ï¼è®¾ç½®ä¸º4M setRebalanceBatchSize(); setIndexedTypes(); //å平衡延è¿æ¶é´ï¼è®¾ç½®ä¸º100 ms setRebalanceThrottle(); //å®ä¹è·åbosUidçsqlå½æ° setSqlFunctionBosUid(); } /** * 使ç¨é»è®¤ååºæ¨¡å¼ * @return CacheConfigurationå®ä¾ */ public CacheConfiguration setDefaultCacheMode() { CacheMode partitioned = CacheMode.PARTITIONED; return super.setCacheMode(partitioned); } /** * åºäºæ§è½åå , 设置å¤ä»½èç¹ä¸º1 * @return CacheConfigurationå®ä¾ */ public CacheConfiguration setDefaultBackups() { return super.setBackups(1); } /** * é»è®¤è®¾ç½®å®¢æ·ç«¯èç¹ä¼çå¾ ä¸»èç¹çåæè æ交æ纵å®æï¼ä½ä¸ä¼çå¾ å¤ä»½èç¹çæ´æ°å®æ * @return CacheConfigurationå®ä¾ */ public CacheConfiguration setDefaultWriteSynchronizationMode() { CacheWriteSynchronizationMode primarySync = CacheWriteSynchronizationMode.PRIMARY_SYNC; return super.setWriteSynchronizationMode(primarySync); } /** * 设置ååå¯ç¨ * @return CacheConfigurationå®ä¾ */ public CacheConfiguration setDefaultWriteBehindEnabled() { return super.setWriteBehindEnabled(true); } /** * 设置é读å¯ç¨ * @return CacheConfigurationå®ä¾ */ public MutableConfiguration setDefaultReadThrough() { return super.setReadThrough(true); } public MutableConfiguration setDefaultWriteThrough() { return super.setWriteThrough(true); } /** * ååç¼åçæ大å¼ï¼å¦æè¶ è¿äºè¿ä¸ªéå¼ï¼ * ææçç¼åæ°æ®é½ä¼è¢«å·å ¥ç¼ååå¨ç¶ååç¼åè¢«æ¸ ç©ºã * å¦æå¼ä¸º0ï¼å·æ°æä½å°ä¼ä¾æ®å·æ°é¢çé´éï¼ * 注æä¸è½å°åç¼å大å°åå·æ°é¢çé½è®¾ç½®ä¸º0 * @return CacheConfigurationå®ä¾ */ public CacheConfiguration setDefaultWriteBehindFlushSize() { return super.setWriteBehindFlushSize(10240); } public CacheConfiguration setWriteBehindBatchSize() { return super.setWriteBehindBatchSize(1); } public CacheConfiguration setDefaultWriteBehindFlushFrequency() { return super.setWriteBehindFlushFrequency(1); } public CacheConfiguration setIndexedTypes(Class clazz){ return super.setIndexedTypes(String.class,clazz); } public CacheConfiguration setWriteBehindFlushThreadCount(){ return super.setWriteBehindFlushThreadCount(3); } public CacheConfiguration setRebalanceBatchSize(){ return super.setRebalanceBatchSize(4*1024*1024); } public CacheConfiguration setRebalanceThrottle(){ return super.setRebalanceThrottle(100); } public CacheConfiguration setSqlFunctionBosUid(){ return
Re: Re:Re: index about jdbc thin mode
Hi, Actually, the same exact code I sent you works as expected on my side. Could you share a reproducer so that I can take a look at it? At least, please Ignite configuration and how you run explain query via thin JDBC driver. Kind regards, Alex -- Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re:Re: index about jdbc thin mode
afedotov, As you say ,you removed JPA related annotations. How to removed? I try as your suggestion, I found if I build a new entity class and use cache.query() ,it will take the index, but still not take the index with JDBC thin mode. What did I miss? Thanks. At 2017-12-04 22:27:40, "afedotov"wrote: >Hi, > >Not sure, what's wrong with your code. >Either IX_T_BD_StatusFid or IX_T_BD_CUSTOMER should have been taken. > >I removed JPA related annotations and checked your code, it gave me the >following plan: >[[SELECT >__Z0.FID AS __C0_0, >__Z0.FNUMBER AS __C0_1 >FROM "customerCache".CUSTOMERIGNITEINFO __Z0 >/* "customerCache".IX_T_BD_STATUSFID: FUSEDSTATUS = 3 */ >WHERE __Z0.FUSEDSTATUS = 3], [SELECT >__C0_0 AS FID, >__C0_1 AS FNUMBER >FROM PUBLIC.__T0 >/* "customerCache"."merge_scan" */]] > >As you can see IX_T_BD_STATUSFID index was used. > >I used the following code to check the case. Could you check it on your >side? > >public class GroupIndexes1Main { > >public static class CustomerIgniteInfo implements Serializable { >private static final long serialVersionUID = -8065741098718964203L; > >@QuerySqlField(index = true, orderedGroups={@QuerySqlField.Group( >name = "IX_T_BD_StatusFid", order = 1)}) >private String FID; > >@QuerySqlField( orderedGroups={@QuerySqlField.Group( >name = "IX_T_BD_StatusFid", order = 2)}) >private String FNUMBER; > >@QuerySqlField(orderedGroups={@QuerySqlField.Group( >name = "IX_T_BD_CUSTOMER", order = 1),@QuerySqlField.Group( >name = "IX_T_BD_StatusFid", order = 0)}) >private Integer FUSEDSTATUS; > >public CustomerIgniteInfo() { >} > >public CustomerIgniteInfo(String FID, String FNUMBER, Integer >FUSEDSTATUS) { >this.FID = FID; >this.FNUMBER = FNUMBER; >this.FUSEDSTATUS = FUSEDSTATUS; >} > >public String getFID() { >return FID; >} >public void setFID(String id) { >this.FID = id; >} > >public String getFNUMBER() { >return FNUMBER; >} > >public void setFNUMBER(String fNUMBER) { >FNUMBER = fNUMBER; >} > >public Integer getFUSEDSTATUS() { >return FUSEDSTATUS; >} > >public void setFUSEDSTATUS(Integer fUSEDSTATUS) { >FUSEDSTATUS = fUSEDSTATUS; >} >} > > >public static void main(String[] args) { >Ignite ignite = Ignition.start(); > >IgniteCache cache = >ignite.getOrCreateCache( >new CacheConfiguration CustomerIgniteInfo>("customerCache") >.setIndexedTypes(Long.class, CustomerIgniteInfo.class) >); > >LongStream.range(0, 10).forEach(l -> { >cache.put(l, new CustomerIgniteInfo("FID" + l, "FNUMBER" + l, >(int)l)); >}); > >List > qryResults = cache.query( >new SqlFieldsQuery("EXPLAIN SELECT FID,FNUMBER FROM >\"customerCache\".CustomerIgniteInfo WHERE FUSEDSTATUS = 3") >).getAll(); >System.out.println(qryResults); >} >} > > > >-- >Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re:Re: index about jdbc thin mode
well, I use jdbc thin mode. It's ok with cache.query(); But It did not work with JDBC thin mode. Thanks.
Re: index about jdbc thin mode
Hi, Just to clarify, the same result I have while running using the thin JDBC driver. Class.forName("org.apache.ignite.IgniteJdbcThinDriver"); try ( Connection conn = DriverManager.getConnection("jdbc:ignite:thin://localhost:10800"); PreparedStatement preparedStatement = conn.prepareStatement( "EXPLAIN SELECT FID,FNUMBER FROM \"customerCache\".CustomerIgniteInfo WHERE FUSEDSTATUS = 3" ); ResultSet resultSet = preparedStatement.executeQuery(); ) { while (resultSet.next()) System.out.println(resultSet.getObject(1)); } -- Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: index about jdbc thin mode
Hi, Not sure, what's wrong with your code. Either IX_T_BD_StatusFid or IX_T_BD_CUSTOMER should have been taken. I removed JPA related annotations and checked your code, it gave me the following plan: [[SELECT __Z0.FID AS __C0_0, __Z0.FNUMBER AS __C0_1 FROM "customerCache".CUSTOMERIGNITEINFO __Z0 /* "customerCache".IX_T_BD_STATUSFID: FUSEDSTATUS = 3 */ WHERE __Z0.FUSEDSTATUS = 3], [SELECT __C0_0 AS FID, __C0_1 AS FNUMBER FROM PUBLIC.__T0 /* "customerCache"."merge_scan" */]] As you can see IX_T_BD_STATUSFID index was used. I used the following code to check the case. Could you check it on your side? public class GroupIndexes1Main { public static class CustomerIgniteInfo implements Serializable { private static final long serialVersionUID = -8065741098718964203L; @QuerySqlField(index = true, orderedGroups={@QuerySqlField.Group( name = "IX_T_BD_StatusFid", order = 1)}) private String FID; @QuerySqlField( orderedGroups={@QuerySqlField.Group( name = "IX_T_BD_StatusFid", order = 2)}) private String FNUMBER; @QuerySqlField(orderedGroups={@QuerySqlField.Group( name = "IX_T_BD_CUSTOMER", order = 1),@QuerySqlField.Group( name = "IX_T_BD_StatusFid", order = 0)}) private Integer FUSEDSTATUS; public CustomerIgniteInfo() { } public CustomerIgniteInfo(String FID, String FNUMBER, Integer FUSEDSTATUS) { this.FID = FID; this.FNUMBER = FNUMBER; this.FUSEDSTATUS = FUSEDSTATUS; } public String getFID() { return FID; } public void setFID(String id) { this.FID = id; } public String getFNUMBER() { return FNUMBER; } public void setFNUMBER(String fNUMBER) { FNUMBER = fNUMBER; } public Integer getFUSEDSTATUS() { return FUSEDSTATUS; } public void setFUSEDSTATUS(Integer fUSEDSTATUS) { FUSEDSTATUS = fUSEDSTATUS; } } public static void main(String[] args) { Ignite ignite = Ignition.start(); IgniteCachecache = ignite.getOrCreateCache( new CacheConfiguration ("customerCache") .setIndexedTypes(Long.class, CustomerIgniteInfo.class) ); LongStream.range(0, 10).forEach(l -> { cache.put(l, new CustomerIgniteInfo("FID" + l, "FNUMBER" + l, (int)l)); }); List > qryResults = cache.query( new SqlFieldsQuery("EXPLAIN SELECT FID,FNUMBER FROM \"customerCache\".CustomerIgniteInfo WHERE FUSEDSTATUS = 3") ).getAll(); System.out.println(qryResults); } } -- Sent from: http://apache-ignite-users.70518.x6.nabble.com/